Welcome Guest Search | Active Topics | Sign In | Register

Treeview Options
Lincoln
Posted: Thursday, November 12, 2009 10:50:35 AM
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
eo_support
Posted: Thursday, November 12, 2009 11:01:44 AM
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
Lincoln
Posted: Thursday, November 12, 2009 5:43:16 PM
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);
}

eo_support
Posted: Thursday, November 12, 2009 6:43:57 PM
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
Lincoln
Posted: Thursday, November 12, 2009 8:54:12 PM
Rank: Newbie
Groups: Member

Joined: 9/16/2009
Posts: 4
Perfect! It worked as expected. thank you very much!
eo_support
Posted: Thursday, November 12, 2009 8:57:08 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Great. Glad it worked for you!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.