Restore Expand CollapseGrouping State for multiple Level

1 reply. Last post: July 7, 2011 2:26 AM by Riendy Setiadi
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Mubarack AliMember

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

 

 
<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

 

 

1 attachment
All times are GMT -5. The time now is 5:54 AM.
Previous Next