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
() {
}
});