<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: GroupBy feature</title>
	<link>http://www.trirand.com/blog/?page_id=393/feature-request/groupby-feature</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/feature-request/groupby-feature/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on GroupBy feature</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/groupby-feature#p4449</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/groupby-feature#p4449</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Thanks for the code. Could you please send me the code to: tony at trirand dot com. It is maybe the first step for this feature.</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Fri, 06 Feb 2009 03:26:41 +0200</pubDate>
        </item>
        <item>
        	<title>seetharaman on GroupBy feature</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/groupby-feature#p4431</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/groupby-feature#p4431</guid>
        	        	<description><![CDATA[<p>I used the existing jqGrid features and simulated the groupBy funtion. This is what I need and it works for me. If a better feature can be provided by jqGrid native code, that will be wonderful. Here is the function I created</p>
</p>
<p>function groupBy1(grid,field)<br />{<br />// grid&#160;&#160;&#160; &#160;&#160;&#160; ==&#62;&#160;&#160;&#160; Name of the grid field<br />// field&#160;&#160;&#160; ==&#62;&#160;&#160;&#160; id name of the field<br />// example&#160;&#160;&#160; ==&#62; groupBy1("#list2","name")<br />// row&#160;&#160;&#160; &#160;&#160;&#160; ==&#62; this is one of the id used to display the row number<br />//&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; and can not be used for group by. If used, it will ungroup<br />//&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; the grid<br />&#160;&#160;&#160; var txt=field;<br />&#160;&#160;&#160; var mya=new Array();&#160;&#160;&#160; &#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // array to hold all the rowid of this grid<br />&#160;&#160;&#160; mya=jQuery("#list2").getDataIDs();&#160; &#160;&#160;&#160; &#160;&#160;&#160; // Get All IDs<br />&#160;&#160;&#160; for(i=0;i&#60;mya.length;i++)<br />&#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; data=jQuery(grid).getRowData(mya[i]);&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // get the row data<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; if(data["row"]=="")jQuery(grid).delRowData(mya[i]);&#160;&#160; // if the row does not contain any value, <br />&#160;&#160;&#160; &#160;&#160;&#160; }&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // delete the row (ungroup)<br />&#160;&#160;&#160; if(field=="row")&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160;&#160; just ungroup and return ; else<br />&#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; jQuery(grid).setGridParam({sortname:txt,sortorder: "asc",}).trigger(&#39;reloadGrid&#39;);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; return;&#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; } &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; jQuery(grid).setGridParam({sortname:txt}).trigger(&#39;reloadGrid&#39;);// sort the grid using the field name<br />&#160;&#160;&#160; mya=jQuery("#list2").getDataIDs();&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // Get All IDs (after deletioo - ungroup)<br />&#160;&#160;&#160; var data=jQuery(grid).getRowData(mya[1]); &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // Get First row to get the labels<br />&#160;&#160;&#160; var oldValue=data[txt];&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // first value<br />&#160;&#160;&#160; var insertHere=mya[0];&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // rowid where the group text has to be inserted<br />&#160;&#160;&#160; var groupCount=0;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // number of rows in the group<br />&#160;&#160;&#160; var dat=new Array();&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // array to store the gheader value<br />&#160;&#160;&#160; for(i=0;i&#60;mya.length;i++)&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // loop thru all rows<br />&#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; data=jQuery(grid).getRowData(mya[i]);&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // get the row contents<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; if(oldValue!=data[txt])&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // if the field value is not same<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; var value=oldValue+" - "+groupCount;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; //&#160;&#160;&#160; Set the test<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; dat[txt]=value;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // set the field value<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; jQuery(grid).addRowData(insertHere,dat, &#39;before&#39;, insertHere);&#160;&#160;&#160; // insert group header<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; jQuery(grid).setCell(insertHere,field,&#39;&#39;,{color:&#39;red&#39;,&#39;text-align&#39;:&#39;left&#39;,&#39;font-weight&#39;:&#39;bold&#39;}); // set color<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; insertHere=mya[i];&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // reset where to insert group header<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; groupCount=0;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // reset group count<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; oldValue=data[txt];&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // rest old value<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; else<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; groupCount++;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // update group count<br />&#160;&#160;&#160; &#160;&#160;&#160; }&#160;&#160;&#160; <br />&#160;&#160;&#160; var value=oldValue+" - "+groupCount;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // set group text for last entry<br />&#160;&#160;&#160; dat[txt]=value;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; // set the value<br />&#160;&#160;&#160; jQuery(grid).addRowData(insertHere,dat, &#39;before&#39;, insertHere);&#160;&#160;&#160; // add the group header <br />&#160;&#160;&#160; jQuery(grid).setCell(insertHere,field,&#39;&#39;,{color:&#39;red&#39;,&#39;text-align&#39;:&#39;left&#39;,&#39;font-weight&#39;:&#39;bold&#39;});// set the color<br />}</p>
</p>
<p>I tested the function using following snippet</p>
<p>&#60;input type="BUTTON" id="bexportid" value="GroupBy" onclick=&#39;var m=$("grby").value;groupBy1("#list2",m);&#39; /&#62; <br />&#60;select id=&#39;grby&#39;&#62;<br />&#160;&#160;&#160; &#60;option value=&#39;row&#39;&#62;UnGroup&#60;/option&#62;<br />&#160;&#160;&#160; &#60;option value=&#39;invdate&#39;&#62;inv date&#60;/option&#62;<br />&#160;&#160;&#160; &#60;option value=&#39;name&#39;&#62;name&#60;/option&#62;<br />&#160;&#160;&#160; &#60;option value=&#39;note&#39;&#62;note&#60;/option&#62;<br />&#160;&#160;&#160; &#60;option value=&#39;amount&#39;&#62;amount&#60;/option&#62;<br />&#160;&#160;&#160; &#60;option value=&#39;tax&#39;&#62;tax&#60;/option&#62;<br />&#160;&#160;&#160; &#60;option value=&#39;total&#39;&#62;total&#60;/option&#62;<br />&#60;/select&#62;</p></p>
]]></description>
        	        	<pubDate>Thu, 05 Feb 2009 16:57:46 +0200</pubDate>
        </item>
        <item>
        	<title>seetharaman on GroupBy feature</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/groupby-feature#p4405</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/groupby-feature#p4405</guid>
        	        	<description><![CDATA[<p>By Looking at the methods you have provided, it appears to me that the requirement I am looking for is doable.&#160; After the grid is loaded, if someone wants to group all the rows by a specific column, we should have a method to do the following:</p>
</p>
<p>Sort the grid on the&#160; column which user wants to do groupby</p>
<p>Add a row at the end of column value change</p>
<p>Add a header with the unique value of the column name in that block with the number of rows in that group. This is the feature that lot of users are looking for to closely look at the results in the grid</p>
]]></description>
        	        	<pubDate>Thu, 05 Feb 2009 04:07:00 +0200</pubDate>
        </item>
</channel>
</rss>