|
Rank: Newbie Groups: Member
Joined: 9/16/2009 Posts: 4
|
Hello
I am using the TreeView component, along with a CallbackPanel, when a node is checked in treeviiw, update a GridView which is inside the CallbackPanel. I'm having a problem using the options AutoCheckChildren and AutoUncheckChildren options set to true. Clicking on a node that has 10 children, the event is fired for each child node. Would it not happen?
Thanks
Lincoln
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Which event is fired for each child node? Can you provide a test page that demonstrates the problem?
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 9/16/2009 Posts: 4
|
The Clientside event OnTreeNodeClick active CallbackPanel the event, which triggers the event to update the GridView.
Treeview:
<eo:TreeView ID="TreeView1" runat="server" Height="100%" onitempopulate="TreeView1_ItemPopulate" StateCookieName="TreeView" Width="100%" onitemcheckstatechanged="TreeView1_ItemCheckStateChanged" ClientSideOnCheckStateChanging="OnTreeNodeClick" AutoScroll="False" AutoCheckChildren="True" AutoUncheckChildren="True" RaisesServerEvent="True"> <LookNodes> <eo:TreeNode ItemID="_Default"> </eo:TreeNode> </LookNodes> <CheckBoxImages Visible="True" /> <TopGroup Style-CssText="cursor:hand"> </TopGroup> </eo:TreeView>
Javascript: function OnTreeNodeClick(e, info) { var node = info.getValue(); eo_Callback("cbPanel", node); }
CBPanel Event: private void cbPanel_Execute(object sender, EO.Web.CallbackEventArgs e) { AtualizaGrid(e.Parameter); }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, This is normal. Because indeed the child node's check state has changed, so it will fire ClientSideOnCheckStateChanging event. You can use a timer to delay eo_Callback and if your OnTreeNodeClick sees a callback is already pending, then it does nothing. It will be something like this:
Code: JavaScript
//Global variable that indicates whether we are about to
//trigger a callback
var callback_pending = false;
function OnTreeNodeClick(e, info)
{
//Does nothing if a callback is about to happen
if (callback_pending)
return;
//Otherwise go ahead and schedule a callback
callback_pending = true;
setTimeout(function()
{
//Reset flag
callback_pending = false;
//Continue with callback
var node = info.getValue();
eo_Callback("cbPanel", node);
}, 20);
}
This way the callback will only be fired once. Hope this helps. Thanks
|
|
Rank: Newbie Groups: Member
Joined: 9/16/2009 Posts: 4
|
Perfect! It worked as expected. thank you very much!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Great. Glad it worked for you!
|
|