<?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: cellEdit + setGridParam data + sort</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/celledit-setgridparam-data-sort</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/help/celledit-setgridparam-data-sort/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>ezhidze on cellEdit + setGridParam data + sort</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/celledit-setgridparam-data-sort#p19552</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/celledit-setgridparam-data-sort#p19552</guid>
        	        	<description><![CDATA[<p>Hi!</p>
<p>I&#39;m trying to made a local data self-expandible table with cellEdit and auto-sorting.</p>
<p>I.e. last row of the table is always blank, and when user fills the first cell in that line, table must reorder itself and add a blank row at the end. After every edit the hidden input&#39;s value must be set to ensure that I can catch entrie array via $_POST.</p>
<p>While I experimented with just &#39;clientSide&#39;, all was almost good &#8211; except for one thing: when reordering the data in the lines were mixed in some strange order.</p>
<p>Then I formed data array, and set .setGridParam({ data: &#8230; }) to it.</p>
<p>Row adding still works, but data isn&#39;t saved anymore.</p>
<p>Second question is how I can made table hard order itself by the first column (len) without letting user to sort any othe way?</p>
<p><input type='button' class='sfcodeselect' name='sfselectit4083' value='Select Code' data-codeid='sfcode4083' /></p>
<div class='sfcode' id='sfcode4083'>
<p>&#60;table id=&#34;pr3tbl1&#8243;&#62;&#60;/table&#62;</p>
<p>&#60;br&#62;&#60;textarea name=&#34;table1input&#34; id=&#34;table1input&#34; cols=&#34;55&#8243;&#62;&#60;/textarea&#62;</p>
<p>&#60;script type=&#34;text/javascript&#34;&#62;</p>
<p>var pr3mdl1 = new Array ();<br />pr3mdl1[0] = {name:&#39;len&#39;,index:&#39;len&#39;,label:&#39;Len,&#34;&#39;, width:60, sortable:true, sorttype:&#39;int&#39;, resizable:false, editable:true,editrules:{number:true}};</p>
<p>var lastCol = 3;<br />for(var i=1;i&#60;=9;i++) {<br />&#160;&#160; &#160;pr3mdl1[i] = {name:&#39;w&#39;+i,index:&#39;w&#39;+i,label:&#34;Col &#34;+i, width:45, sortable:false, resizable:false, editable:true, editrules:{number:true}, hidden: (i &#62; lastCol)}<br />}</p>
<p>pr3tbl1Grid = jQuery(&#34;#pr3tbl1&#8243;).jqGrid({<br />&#160;&#160; &#160;datatype: &#34;clientSide&#34;,<br />&#160;&#160; &#160;colModel: pr3mdl1,<br />&#160;&#160; &#160;loadonce: true,<br />&#160;&#160; &#160;height: &#34;100%&#34;,</p>
<p>&#160;&#160; &#160;cellEdit: true,<br />&#160;&#160; &#160;cellsubmit: &#39;clientArray&#39;,</p>
<p>&#160;&#160; &#160;viewsortcols: [false,&#39;vertical&#39;,false],</p>
<p>&#160;&#160; &#160;caption:&#34;Length, yd:&#34;,</p>
<p>&#160;&#160; &#160;sortname: &#39;len&#39;,<br />&#160;&#160; &#160;sortorder: &#39;desc&#39;,</p>
<p>&#160;&#160; &#160;afterSaveCell:&#160; function(rowid,celname,value,iRow,iCol) {<br />&#160;&#160; &#160;&#160;&#160; &#160;if(this.reccount &#60;= rowid) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;rowLen = jQuery(&#34;#&#34;+this.id).getCell(rowid, &#39;len&#39;);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if (rowLen != &#34;&#34;) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;jQuery(&#34;#&#34;+this.id).setGridParam({sortname:&#39;len&#39;}).trigger(&#39;reloadGrid&#39;);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;jQuery(&#34;#&#34;+this.id).addRowData(this.reccount + 1,{len:&#34;&#34;,w1:&#34;&#34;,w2:&#34;&#34;,w3:&#34;&#34;},&#39;last&#39;);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;jQuery(&#34;#table1input&#34;).val(pr3tbl1Data.toJSON());<br />&#160;&#160; &#160;}<br />});</p>
<p>var pr3tbl1Data = [<br />&#160;&#160; &#160;{len:&#34;24&#34;,w1:&#34;1&#34;,w2:&#34;35&#34;,w3:&#34;24.24&#34;},<br />&#160;&#160; &#160;{len:&#34;50&#34;,w1:&#34;2&#34;,w2:&#34;35&#34;,w3:&#34;50.50&#34;},<br />&#160;&#160; &#160;{len:&#34;45&#34;,w1:&#34;3&#34;,w2:&#34;45&#34;,w3:&#34;&#34;},<br />&#160;&#160; &#160;{len:&#34;&#34;,w1:&#34;&#34;,w2:&#34;&#34;,w3:&#34;&#34;}<br />];</p>
<p>pr3tbl1Grid.setGridParam({ data: pr3tbl1Data });<br />pr3tbl1Grid[0].refreshIndex();<br />pr3tbl1Grid.trigger(&#34;reloadGrid&#34;);</p>
<p>&#60;/script&#62;</p>
</div>
]]></description>
        	        	<pubDate>Mon, 06 Sep 2010 20:34:50 +0300</pubDate>
        </item>
</channel>
</rss>