Hi Telerik team,
I'm using Radgrid to build a tree structure with source of objects with parent and child relationship,
and the configuration of the grid as below:
Everything works fine until when one of the node is expanded to more that 1 level, and refresh the page (based on some criteria so that the data source now has changed), the following error appears:
Specified argument was out of the range of valid values. Parameter name: ItemHierarchicalIndex
Some additional info on the error:
Apparently the problem is on client state data "expandedItems", i guess it is trying to restore the expanded items on the new data source (which has been changed and the expanded levels in client data may not be valid anymore).
I'm not quite sure about my observation, but i've tried to override the LoadClientState function in my custom grid:
It does the trick and the page is successfully refreshed no matter how many level of nodes i expanded before.
However i would like to know is there any better solution for this, and why does this happen?
Thanks.
I'm using Radgrid to build a tree structure with source of objects with parent and child relationship,
and the configuration of the grid as below:
MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
MasterTableView.HierarchyDefaultExpanded =
false
;
MasterTableView.SelfHierarchySettings.KeyName =
"xxx"
;
MasterTableView.SelfHierarchySettings.ParentKeyName =
"yyy"
;
ClientSettings.AllowExpandCollapse =
true
;
ClientSettings.AllowColumnsReorder =
false
;
ClientSettings.ReorderColumnsOnClient =
true
;
Everything works fine until when one of the node is expanded to more that 1 level, and refresh the page (based on some criteria so that the data source now has changed), the following error appears:
Specified argument was out of the range of valid values. Parameter name: ItemHierarchicalIndex
Some additional info on the error:
Source | Telerik.Web.UI |
Function | Telerik.Web.UI.GridDataItem get_Item(System.String) |
Stack | Telerik.Web.UI.GridDataItemCollection.get_Item(String
hierarchicalIndex) Telerik.Web.UI.RadGrid.LoadClientState(Dictionary`2 clientState) System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) |
myGrid_ClientState | {"selectedIndexes":[],"reorderedColumns":[],"expandedItems":["1","1","0","0","1","1","0","0","1","1","0","0","0:0_10","0"],"expandedGroupItems":[],"expandedFilterItems":[],"deletedItems":[],"hidedColumns":[],"showedColumns":[],"popUpLocations":{},"draggedItemsIndexes":[]} |
Apparently the problem is on client state data "expandedItems", i guess it is trying to restore the expanded items on the new data source (which has been changed and the expanded levels in client data may not be valid anymore).
I'm not quite sure about my observation, but i've tried to override the LoadClientState function in my custom grid:
protected
override
bool
LoadClientState(Dictionary<
string
,
object
> clientState)
{
if
(clientState.ContainsKey(
"expandedItems"
))
clientState[
"expandedItems"
] =
new
object
[] { };
return
base
.LoadClientState(clientState);
}
It does the trick and the page is successfully refreshed no matter how many level of nodes i expanded before.
However i would like to know is there any better solution for this, and why does this happen?
Thanks.