This is a migrated thread and some comments may be shown as answers.

self-referencing hierarchy: binding data on client object

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
cem
Top achievements
Rank 1
cem asked on 21 Jan 2011, 05:04 PM

Hi,
I have created a RadGrid with self-referencing hierarchy without a problem. But as we are having some performance issues I don't have the luxure to send/receive big page sizes each time. So I send the grid empty without binding the data on needDataSource event. Then I get the data with ajax in json format which is quite small. The problem is I cannot find a client side event, which formats the data with the given hierarchical structure. Is there a way for that or do I need to write a custom javascript function to create that structure?

Where should I assign the filter expression on client side, which I do on server side like t.MasterTableView.FilterExpression = @"it[""PARENT""] = Convert.DBNull";

Given code creates the grid and binds the data but without a structure.

Thanks in advance,

Cem

<telerik:RadGrid ID="t" runat="server" AutoGenerateColumns="false" AllowPaging="True"
            HierarchyDefaultExpanded="false" HierarchyLoadMode="Client" AllowSorting="True"
            PageSize="10"
            <mastertableview datakeynames="CHILD,PARENT"
                <SelfHierarchySettings ParentKeyName="PARENT" KeyName="CHILD" /> 
                <Columns
                    <telerik:GridBoundColumn DataField="CHILD" HeaderText="CHILD"
                    </telerik:GridBoundColumn
                    <telerik:GridBoundColumn DataField="PARENT" HeaderText="PARENT"
                    </telerik:GridBoundColumn
                    <telerik:GridBoundColumn DataField="AMOUNT" HeaderText="AMOUNT" >                
                    </telerik:GridBoundColumn
                </Columns
            </mastertableview
            <clientsettings allowexpandcollapse="true" selecting-allowrowselect="true" enablerowhoverstyle="false"
                <Scrolling AllowScroll="True" ScrollHeight="400px" UseStaticHeaders="True" />                 
            </clientsettings
        </telerik:RadGrid>


Sys.Application.add_init(function() { 
        var grid = $find("<%=t.ClientID%>"); 
        var tableView = grid.get_masterTableView(); 
        var id = grid.get_element().id; 
        var objData = { 
            id: id, 
            startIndex: tableView.get_currentPageIndex(), 
            pageSize: tableView.get_pageSize(),             
        }; 
    
        $.ajax({ 
            type: "POST"
            url: url, 
            data: Sys.Serialization.JavaScriptSerializer.serialize({ data: objData }), 
            contentType: "application/json; charset=utf-8"
            success: function(arg) { 
                //create an array with coming data and assign it         
                tableView.set_dataSource(arr); 
                tableView.dataBind(); 
                }, 
                before: function() { 
                }, 
                error: function() { 
                
            });

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 26 Jan 2011, 03:05 PM
Hello,

RadGrid does not support hierarchical structures with client-side binding. The only option to avoid postbacks on some actions in the grid is to use HierarchyLoadMode Client.

All the best,
Tsvetina
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.
Tags
Grid
Asked by
cem
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or