|
Rank: Member Groups: Member
Joined: 5/12/2009 Posts: 20
|
Can I programmatically update the contents of a callbackpanel?
Within the callbackpanel's OnExecute routine I would like to execute another calbackpanel's execute routine. I can call the callback routine directly from code, but this has no effect - the controls on the second callbackpanel are not updated.
Example:
I have several callbackpanels, each with a listbox on it.
Selecting an item in the first list, will fill the second list. Selecting an item in the second list then will fill the third one and so on. This works fine. If I now clear the selection of the first listbox, the second listbox is cleared by the callback routine but this does NOT trigger the third callback routine. So the third list will not be cleared automatically.
So how can I trigger a collbackpanel's onExecute-Routine from another callbackpanel's OnExecute-routine without client interaction?
Any help appreciated!
Ralph
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The easiest way for this situaiton is to set both CallbackPanel's GroupName to the same value. This way when one CallbackPanel updates, the other one will also be updated.
Triggering OnExecute event is a totally different matter. One CallbackPanel will never trigger another CallbackPanel's OnExecute event. However assuming both CallbackPanels are being updated, all you needed to do is to call the same code that B's OnExecute is calling inside A's OnExecute.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/12/2009 Posts: 20
|
Isn't this approach similar to putting all the listboxes on one callbackpanel?
I tried that one before and I ran into the problem that the selections in the listboxes are always lost as I populate the listboxes with every callback.
Another approach I tried was adding multiple triggers to my controlpanels:
First panel has only trigger 1 Second panel would have 2 and 1 Third panel would have 3, 2 and 1
But here it seems that only one callback can be triggered: If I click on my triggering control (trigger 1) the OnExecute of CallbackPanel1 is called but not the other two callback routines.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
ListBox losing selection is a problem itself and needed to be worked out. That can be the root of the problem so no matter how you arrange the CallbackPanels, as soon as that problem still exist, you will not have a working solution. So I would suggest you to:
1. Update to the latest version first; 2. Try to isolate the problem into a separate test page first. If you can reproduce the problem in the test page we will be happy to take a look. Make sure the test page runs independently;
You can not trigger multiple CallbackPanel with a single trigger. You can only group them together so that they update together. However as stated in our previous reply, one CallbackPanel will never trigger another CallbackPanel's OnExecute event. So if you group A and B together, then click one of A's trigger, in this case:
1. A is triggered (it's OnExecute is called); 2. B is not triggered (It's OnExecute is not called); 3. Both A and B are updated;
Group CallbackPanel together has an advantage over putting all list boxes on one CallbackPanel because different CallbackPanels can be placed at separate location of the page. For example, if your ListBoxA is at the top of the page and ListBoxB is at the bottom of the page, you can use two CallbackPanels and group them together. Otherwise you would have to use a single CallbackPanel covering from the page top to the bottom and include many other page elements inside the CallbackPanel.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/12/2009 Posts: 20
|
Thank you! I finally figured it out! Now I have my 4 listboxes on 4 callbackpanels. All 4 callbackpanels are calling the same onExecute-routine which populates all 4 listboxes. I have to set programmatically all the selections already done to avoid loosing them. Only the first callbackpanel has a triggering control - all other Execute-Routines are triggered by callbackPanel's ChildrenAsTriggers=true. It works great! Thanks again!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Cool. Glad that you got it working!
|
|