Welcome Guest Search | Active Topics | Sign In | Register

TreeView ItemPopulate and ClientOnItemClick Options
Simon
Posted: Friday, September 9, 2011 9:02:52 AM
Rank: Member
Groups: Member

Joined: 8/19/2011
Posts: 15
I have a treeview on the left side of the screen which I need the PopulateOnDemand feature to be set on, this I have done, but I also need to update a grid in the right hand side of the screen at the same time when you click on a node, I have the OnItemPopulate method working fine, now the problem seems to be how to update the grid when ItemClick is fired, I need all this to happen on the Client, so the treeview RaiseServerEvents is false, at the moment the following code seems to work but I wanted to make sure this was the best way of making this happen:

I have the grid inside an UpdatePanel, this grid is triggered by the Button Click method.

TreeView
ClientSideAfterPopulate="RefreshGrid"
ClientSideOnItemClick = "OnItemClick"

Javascript code is:
Code: JavaScript
// TreeView Handle the OnItemClick
        function OnItemClick(e, eventInfo) {

            var node = eventInfo.getItem();
            var nodeValue = node.getValue();

            if (nodeValue != '') {  // Empty is the Root Node.
                // need to do a call back to get documents, this call back needs to
                // be done without the whole page posting back.
                var obj = document.getElementById('<%= text.ClientID %>');
                obj.value = nodeValue;
          
            setTimeout(function() {
                RefreshGrid();
            }, 10);
        }
}

        function RefreshGrid(treeView, node) {
            var button = document.getElementById('<%= btnRefreshList.ClientID %>');
            button.click();
        }


I have tried other ways, but this seems to stop the ItemPopulate from working, any ideas on how to streamline this would be helpful,

Thanks
Simon.
eo_support
Posted: Friday, September 9, 2011 10:45:44 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can try to do other way: refresh the Grid first, then populate the child tree nodes. It will be something like this:

1. Handle the TreeView's ClientSideItemClick event to trigger the Grid refresh:

Code: JavaScript
var nodeToExpand;
function click_handler(e, info)
{
    //Save the node that needs to be expanded
    nodeToExpand = info.getItem();

    //Trigger the callback
    ......    
}


2. Handle the CallbackPanel's ClientSideAfterUpdate event to trigger populate on demand:

Code: JavaScript
function after_update()
{
    //Delay the call to allow the CallbackPanel finishes first
    setTimeout(function()
    {
        //Trigger populate on demand on the last clicked node
        if (nodeToExpand)
            nodeToExpand.populateOnDemand();
    }, 10);
}


Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!


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.