clahti2
Posts: 107
|
Posted: 02/15/2012, 5:26 PM |
|
Hello all:
I am trying to figure out the RemoteCustomCode feature of an update panel. Here is what I am trying to do. Let's assume you have the following tables:
table foogroups
groupid int(11), autoinc,not null
group_name varchar(25)
flg_trans tinyint(4)
flg_userid int(11)
table fooitems
itemid int(11), autoinc not null
groupid int(11) foreign key -> foogroups.groupid
item_name varchar(25)
table transactions
transid int(11), autoinc,not null
itemid int(11) foreign key -> fooitems.itemid
flg_userid int(11)
trans_date date
The first page has an editable grid where the user selects select one or more lines from the foogroups table, setting the flg_trans to 1 or 0 via checkboxes. Upon submit the foogroups table is updated with the checked flg_trans and the current CCGetUserID(). All is peachy so far. I then have a "process" page which will do the following (in pseudo-code):
select * from foogroups where flg_trans=1 and flg_userid={CCGetUserID}
for each $groupid (foogroups)
select * from fooitems where groupid={$groupid}
foreach $itemid (fooitems) {
insert into transactions (itemid,userid,trans_date) values $itemid, $userid, now()
//UPDATE AN UPDATE PANEL HERE WITH MESSAGE
}
update foogroups set (flg_trans=0,flg_userid=NULL) where groupid=$groupid
}
This is all good, but what I need is a "display" page show a running update of messages sent back from the "process" page, like "transaction for {recordid} inserted<br>". So I am thinking I need an update panel with a RemoteCustomCode feature to call the"process" page, and some control inside that receives the insert messages. I hope this makes sense, there is zero documentation on the RemoteCustomCode Ajax feature, but I am convinced this is what I need but no clue how to implement. Can anyone shed some light? I am also going to ask CCS support, any solution will be posted here for posterity
|
|
|
clahti2
Posts: 107
|
Posted: 02/19/2012, 5:41 PM |
|
so here is an update since I have unfortunately I have not received any insight from CCS support (yet). Let me explain more concretely what I am trying to do. I have a process that is going to effect more than a thousand transactions in a go, some database, some file manipulation. For each operation I write out a transactionlog table, so this table gets a bunch of inserts while this is going. Because I expect this to take a while, I have split the logic into four separate php pages, all of which insert into the transactionlog table while they do their thing. This all works just fine, however I have a "view" page where the user is supposed to be seeing progress, so on this page I have an update panel and a grid that refreshes with a 2 second javascript timer. This works fine (see my example in the Tips and Tricks forum section for timer-based ajax-panel refresh). So, the problem is I need to call these four pages with an asynchronous ajax call, I have this logic and it works:
|
|
|
clahti2
Posts: 107
|
Posted: 02/19/2012, 5:44 PM |
|
Ah geez the forum will not let me post the javascript!!!
|
|
|
clahti2
Posts: 107
|
Posted: 02/19/2012, 5:49 PM |
|
So the forum does not allow me to post the javascript code, it is based on http://www.codingforums.com/showthread.php?t=162518. The function is copied four times, once for each page that processes transactions. I am sure I could just pass in the page name to the function but this works fine, this is not the issue, each function calls the next page when onreadystatechange returns 4 (completed). This all works fine, the issue is even though these are asynchronous calls, when the timer fires I see the red "updating" flash in the right corner so I know the AjaxPanel.reload($("Panel1")); is firing, however the grid does not refresh. Once step4 is complete and the user gets the alert, THEN the grid refreshes, but only sometimes. I know this is a bit more technical than your run of the mill database thingy but this is only one of a few more tough hurdles I have to overcome on this project. Any help with this would be greatly appreciated, I am sure the RemoteCustomCode was put in there by CCS folks for a reason however there is ZERO documentation or examples on how to use this feature. I am happy to setup a test project and email to someone with what I have so far if this helps. I can make a self contained pdo:sqlite example if necessary, however the production code is php/mysql.
|
|
|
clahti2
Posts: 107
|
Posted: 02/21/2012, 2:46 PM |
|
so I am still waiting for a response from CCS on the RemoteCustomCode, as soon as CCS devs get back to me on this I will update this post. In the meantime I solved the problem with prototype and an ajax progress bar since I had to get past this issue. I will post in the Tips section how to do multiple asynchronous ajax calls and updating a progress bar when I have time, the solution I came up with eventually is actually quite cool
|
|
|
|