iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello,
I was using Webgrid grouping and like to restore the Expand and Collapse grouping state while refresh/Sort.
I was try to implemate the code given in the Intersoft community which using WebGrid1_OnGroupCollapse,WebGrid1_OnGroupExpand,WebGrid1_OnAfterResponseProcess
WebGrid1_OnGroupCollapse,WebGrid1_OnGroupExpand,WebGrid1_OnAfterResponseProcess
<script type="text/javascript"> <!-- //expandedGroupNodes is a global variable string that keeps the expanded group nodes state var expandedGroupNodes; function WebGrid1_OnGroupExpand(controlId, tblName, groupIndex, rowPosition, rowIndex) { var WebGrid1 = ISGetObject(controlId); var CurrentPage = WebGrid1.CurrentPageIndex; //obtain current page index of expanded group node //invoke StoreExpandGroupNode method and passing current page index, row position, and action parameter //action is set to true if the group node is expanded StoreExpandedGroupNode(CurrentPage, rowPosition, true); return true; } function WebGrid1_OnGroupCollapse(controlId, tblName, groupIndex, rowPosition, rowIndex) { var WebGrid1 = ISGetObject(controlId); var CurrentPage = WebGrid1.CurrentPageIndex; //obtain current page index of collapsed group node //invoke StoreExpandGroupNode method and passing current page index, row position, and action parameter //action is set to false if the group node is collapsed StoreExpandedGroupNode(CurrentPage, rowPosition, false); return true; } function WebGrid1_OnAfterResponseProcess(controlId, actionName, lastRequestObject, xmlResponseObject) { var WebGrid1 = ISGetObject(controlId); //if Paging or ColumnSort or Refresh action, restore the group nodes state of current page if (actionName == "Paging") if (expandedGroupNodes != null) { var PageRowInfo = expandedGroupNodes.split(";"); for (var i = 0; i < PageRowInfo.length; i++) { var Page = PageRowInfo[i].split("#")[0]; var Row = PageRowInfo[i].split("#")[1]; if (WebGrid1.CurrentPageIndex == Page) WebGrid1.RootTable.GetRowByGroup(0, Row).ExpandGroupRow(); } } return true; } function StoreExpandedGroupNode(PageIndex, RowIndex, action) { if (action) { //expanded group node state will be kept in 'n#m' //n is the page index of expanded group node //# is used as delimiter between page index and row position of expanded group node //m is the row position of expanded group node if (expandedGroupNodes == null) expandedGroupNodes = PageIndex + "#" + RowIndex; else expandedGroupNodes += ";" + PageIndex + "#" + RowIndex; } else { //obtain the information about PageIndex and RowPosition delimited by ";" var PageRowInfo = expandedGroupNodes.split(";"); var expandedGroupNodesTemp; //get the Page and Row info of expanded group node //and compare it with current PageIndex and RowIndex of collapsed group node for (var i = 0; i < PageRowInfo.length; i++) { var Page = PageRowInfo[i].split("#")[0]; var Row = PageRowInfo[i].split("#")[1]; //if (PageIndex != Page && RowIndex != Row) { if (PageIndex != Page) { if (expandedGroupNodesTemp == null) expandedGroupNodesTemp = PageRowInfo[i]; else expandedGroupNodesTemp += ";" + PageRowInfo[i]; } else { if (RowIndex != Row) { if (expandedGroupNodesTemp == null) expandedGroupNodesTemp = PageRowInfo[i]; else expandedGroupNodesTemp += ";" + PageRowInfo[i]; } } } expandedGroupNodes = expandedGroupNodesTemp; } } --> </script>
But This is working only for one level of grouping , if we try for more than one level its not restore properly.
Please let us know if anyway to find childRow position to fix this problem.
Regards
Mubarack
Hello Mubarack,
This code has a logic that can restore only for first level of grouping. To restore more than one level of childRow, you need to add other variable that can store not only row index but also group index in the WebGrid, and other logic to restore.
Here I attach a simple runable sample that show you how to restore Expand and collapse grouping state for multiple level in WebGrid.
Hope this helps.Riendy
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname