TreeView which updates Grid

2 posts, 0 answers
  1. David
    David avatar
    125 posts
    Member since:
    Jan 2011

    Posted 28 Jan 2011 Link to this post

    I am currently evaluating the Telerik suite of tools and trying to write a sample program to provide my management with justification for the purchase of the suite.  In doing so I am trying to use the Ajax based suite of products for the first time.

    Currently I have a master page with three content panels. 

    My Tree View is defined with:
        <telerik:RadTreeView runat="Server" ID="HDQueuesTreeView" OnNodeClick="HDQueuesTreeView_NodeClick"
            EnableViewState="False" DataFieldID="NODE_ID" OnClientNodeClicked="onNodeClicking_HDQueuesTreeView"
            DataTextField="DISPLAY_TEXT" DataFieldParentID="PARENT_NODE"
             DataValueField="OBJECT_AS_XML" >
                <telerik:RadTreeNodeBinding ToolTipField="TOOL_TIP_TEXT" TextField="DISPLAY_TEXT" ValueField="OBJECT_AS_XML" />

    My Grid is defined in another content panel with:

    <telerik:RadGrid ID="HDQueueGrid" runat="server" AutoGenerateColumns="False"
                    Height="100%" BorderWidth="0px" AllowSorting="True" Style="outline: none" ShowGroupPanel="True"
                        <CommandItemSettings ExportToPdfText="Export to Pdf" />
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px" />
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px" />
    (I snipped out all the columns)
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    <ClientSettings ReorderColumnsOnClient="True" AllowColumnsReorder="True" AllowDragToGroup="True">
                        <Selecting AllowRowSelect="True" />
                    <FilterMenu EnableImageSprites="False">
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">

    The tree view control populates and the click events fire the required Ajax request to the server.  The server side onnodebound events fire.  The server side OnClick events never fire.  The server side Ajax manager request does fire and it seems to work.  My current Ajax event is as follows:
    protected void MyQueuesAjaxManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
                //Use the Deserialize method to create a RadTreeNode object from the JSON string representing the node
                RadTreeNode clickedNode = new JavaScriptSerializer().Deserialize<RadTreeNode>(e.Argument);
                if (clickedNode != null)
                    if (u != null)
                        QB_LAST_CLICKED = XMLSerial.DeserializeObject<QUEUE_BUTTONS>(u, clickedNode.Value);
                        if (QB_LAST_CLICKED != null)
                            this.Session["LAST_CLICKED_QUEUE"] = QB_LAST_CLICKED;
    My Grids "NeedsDataSource" event is as follows:
    protected void HDQueueGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
                List<QUEUE_CONTENTS> QC_LIST = null;

                if ((u != null) &&
                    (this.IsPostBack == true))
                    if ((QB_LAST_CLICKED != null) &&
                        (e.IsFromDetailTable == false))
                        QC_LIST = QUEUE_CONTENTS.READDB(u, QB_LAST_CLICKED);
                HDQueueGrid.DataSource = QC_LIST;
    I have confirmed that the datasource does in fact get populated. I just cannot seem to visually show the data.  The display content area which "hosts" the grid control is blank.

    In case you wish to see my Ajax Manager code:

       <telerik:RadAjaxManager runat="server" ID="MyQueuesAjaxManager"
                <telerik:AjaxSetting AjaxControlID="HDQueuesTreeView">
                        <telerik:AjaxUpdatedControl ControlID="HDQueueGrid"
                            LoadingPanelID="HDAjaxLoadingPanel"  />
    I do not know if it is relevant but this snipped of code is located in the content panel with the TreeView control.

    So what am I doing incorrectly?  I would revert the project to using a data source on the grid except that I cannot seem to derive the selectedvalue from the treeview control.  Those values are always an empty string.  (The treeview control is bound to a List<QUEUE_BUTTON> objects)

    The treeview is populated using in the page load event using:

    if (u != null)
                    if (this.IsPostBack == false)
                        HDQueuesTreeView.DataSource = QUEUE_BUTTONS.READDB(u);

    Thank you for any pointers you can send my way.

  2. Nikolay Tsenkov
    Nikolay Tsenkov avatar
    734 posts

    Posted 03 Feb 2011 Link to this post

    Hello David,

    The problem seems to be that you are not specifying the TreeView itself as an UpdatedControl (you only include the Grid there).
    Please, include the TreeView in UpdatedControls and remove the AjaxRequest event handler (if it isn't needed anymore).

    Nikolay Tsenkov
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top