﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - Restore Expand CollapseGrouping State for multiple Level</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Restore-Expand-CollapseGrouping-State-for-multiple-Level/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Restore Expand CollapseGrouping State for multiple Level</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Restore-Expand-CollapseGrouping-State-for-multiple-Level/</link><pubDate>Thu, 07 Jul 2011 02:26:37 GMT</pubDate><dc:creator>Riendy</dc:creator><category>Restore Expand</category><description>&lt;p&gt;Hello Mubarack,&lt;/p&gt;&lt;p&gt;&lt;br /&gt;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.&lt;/p&gt;
&lt;p&gt;Here I attach a simple runable sample that show you how to restore Expand and collapse grouping state for multiple level in WebGrid.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps.&lt;br /&gt;Riendy&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="line-height: 17px; color: rgb(63, 63, 63); font-family: 'segoe ui', arial, verdana, tahoma; font-size: 12px; " /&gt;&lt;/p&gt;
&lt;h2 id="ctl00_ctl00_ctl00_ctl00_a_b_c_e_ThreadTitle" style="font-family: 'segoe ui', arial, verdana, tahoma; text-align: left; margin-top: 0px; margin-right: 0px; margin-bottom: 2px; margin-left: -1px; padding-top: 3px; padding-right: 0px; padding-bottom: 3px; padding-left: 0px; font-size: 21px; font-weight: 400; line-height: 30px; "&gt;&lt;br /&gt;&lt;/h2&gt;
&lt;p /&gt;</description></item><item><title>Restore Expand CollapseGrouping State for multiple Level</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Restore-Expand-CollapseGrouping-State-for-multiple-Level/</link><pubDate>Wed, 06 Jul 2011 09:27:55 GMT</pubDate><dc:creator>MubaursIT</dc:creator><category>Restore Expand</category><description>&lt;p&gt;&lt;span type="sp" iserror="false" originaltext="Hello,"&gt;Hello,&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span type="sp" iserror="false" originaltext="         "&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="I"&gt;I &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="was"&gt;was &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="using"&gt;using &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="Webgrid"&gt;Webgrid &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="grouping"&gt;grouping &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="and"&gt;and &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="like"&gt;like &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="to"&gt;to &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="restore"&gt;restore &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="the"&gt;the &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="Expand"&gt;Expand &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="and"&gt;and &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="Collapse"&gt;Collapse &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="grouping"&gt;grouping &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="state"&gt;state &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="while"&gt;while &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="refresh/Sort."&gt;refresh/Sort.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span type="sp" iserror="false" originaltext="I"&gt;I &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="was"&gt;was &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="try"&gt;try &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="to"&gt;to &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="implemate"&gt;implemate &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="the"&gt;the &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="code"&gt;code &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="given"&gt;given &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="in"&gt;in &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="the"&gt;the &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="Intersoft"&gt;Intersoft &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="community"&gt;community &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="which"&gt;which &lt;/span&gt;&lt;span type="sp" iserror="false" originaltext="using"&gt;using &lt;/span&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;p&gt;&lt;strong&gt;&lt;span type="sp" iserror="false" originaltext="WebGrid1_OnGroupCollapse,"&gt;WebGrid1_OnGroupCollapse,&lt;/span&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;span type="sp" iserror="false" originaltext="WebGrid1_OnGroupExpand,"&gt;WebGrid1_OnGroupExpand,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;strong&gt;&lt;span type="sp" iserror="false" originaltext="WebGrid1_OnAfterResponseProcess"&gt;WebGrid1_OnAfterResponseProcess&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;span style="font-size: 13px; font-family: consolas"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;
&lt;/span&gt;&lt;/span&gt;&amp;nbsp; 
&lt;pre&gt;&amp;lt;script type="text/javascript"&amp;gt;

&amp;lt;!--

//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 &amp;lt; PageRowInfo.length; i&amp;#43;&amp;#43;) {

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 &amp;#43; "#" &amp;#43; RowIndex;

else

expandedGroupNodes &amp;#43;= ";" &amp;#43; PageIndex &amp;#43; "#" &amp;#43; 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 &amp;lt; PageRowInfo.length; i&amp;#43;&amp;#43;) {

var Page = PageRowInfo[i].split("#")[0];

var Row = PageRowInfo[i].split("#")[1];

//if (PageIndex != Page &amp;amp;&amp;amp; RowIndex != Row) {

if (PageIndex != Page) {

if (expandedGroupNodesTemp == null)

expandedGroupNodesTemp = PageRowInfo[i];

else

expandedGroupNodesTemp &amp;#43;= ";" &amp;#43; PageRowInfo[i];

}

else {

if (RowIndex != Row) {

if (expandedGroupNodesTemp == null)

expandedGroupNodesTemp = PageRowInfo[i];

else

expandedGroupNodesTemp &amp;#43;= ";" &amp;#43; PageRowInfo[i];

}

}

}

expandedGroupNodes = expandedGroupNodesTemp;

}

}

--&amp;gt;

&amp;lt;/script&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;/span&gt;&lt;/span&gt; But This is working only for one level of grouping , if we try for more than one level its not restore properly.&lt;/p&gt;
&lt;p&gt;Please let us know if anyway to find childRow position to fix this problem.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Mubarack&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;</description></item></channel></rss>