on Mar 28, 2012
I have a self-referencing grid. I'm declaring it and configuring it all in the aspx declaration and binding it via the "rebind"-"needs-data" approach. It works fantastic.
The grid is initialized with a large data set (using the HierarchyLoadMode="ServerOnDemand") mode, and I have some PreRender code that expands the first 2 levels of the hierarchy.
Now the user can filter data, we are not using the grids filter but re-querying the database and returning a new dataset and rebinding to the grid. If that dataset contains less than 20 records, the user wants all the nodes expanded by default, otherwise only the first 2.
I've tried several approaches:
1.) Expanding in pre-render. Doesn't work, only 2 sub-layers have data.
2.) changing HierarchyLoadMode to "ServerBind" and expanding in Pre-Render using a recursive expand function (code listed below) Seems to work until the 4th sub-level, after the 4th sublevel the item.ChildItem.NestedTableViews.count is 0, even though I know there are 6 levels in the data set.
My next step is to try it with HierarchyLoadMode = "client" and my last ditch effort to dynmically build the grid for every request. any guidence would be appreciated.
protected void RadGrid1_PreRender(object sender, EventArgs e)
private void RadGridExpandHierarchy(GridDataItemCollection items)
foreach (GridDataItem item in items)
if (item.GetDataKeyValue("IsPolicyRow").ToString()=="0" && item.ChildItem != null && item.ChildItem.NestedTableViews != null && item.ChildItem.NestedTableViews.Count() > 0)
GridTableView childtableView = (GridTableView)item.ChildItem.NestedTableViews;
if (item.CanExpand && item.GetDataKeyValue("IsPolicyRow").ToString() == "0")
item.Expanded = true;