<?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: Inline edit: rowid update &#38; dates</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates</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/inline-edit-rowid-update-dates/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>ignrac on Inline edit: rowid update &#38; dates</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates#p12196</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates#p12196</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I&#39;ve made the following changes to the code:</p>
<p>grid.inlinedit.js<br />+ 158&#160;&#160;&#160;&#160;&#160;&#160; <strong>post_tmp = $.extend({},tmp);</strong><br />- 161&#160;&#160;&#160;&#160;&#160;&#160; data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData(tmp) : tmp,<br />+ 161&#160;&#160;&#160;&#160;&#160;&#160; data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData(<strong>post_tmp</strong>) : tmp,</p>
<p>grid.formedit.js<br />+ 807&#160;&#160;&#160;&#160;&#160;&#160; <strong>post_tmp = $.extend({},postdata);</strong><br />- 811&#160;&#160;&#160;&#160;&#160;&#160; data: $.isFunction(rp_ge.serializeEditData) ? rp_ge.serializeEditData(postdata) :&#160; postdata,<br />+ 811&#160;&#160;&#160;&#160;&#160;&#160; data: $.isFunction(rp_ge.serializeEditData) ? rp_ge.serializeEditData(<strong>post_tmp</strong>) :&#160; postdata,</p>
<p>Now, in last example sequence (dates with datepicker):</p>
<p>Inline input: 15 Dic 2009 (ok)<br />Set Inline input with datepicker: 24 Dic 2009 (ok)<br />serializeRowData: function (postada) postdata.espdate: 24 Dic 2009 (ok)<br />espdate POST: 2009-12-24 (ok, after parse function ig_sqlDate(postdata.espdate))<br />Grid after post: 24 Dic 2009 (now ok)</p>
<p>I will continue doing tests on other formats (numbers, custom, etc.).</p>
<p>Best Regards,</p>
]]></description>
        	        	<pubDate>Thu, 19 Nov 2009 12:54:15 +0200</pubDate>
        </item>
        <item>
        	<title>ignrac on Inline edit: rowid update &#38; dates</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates#p12105</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates#p12105</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Sorry, I think badly explained, the problem is:<br />the data posted, show it in grid after post.</p>
<p>In last example sequence (dates with datepicker or manual entry in newformat):</p>
<p>Inline input: 15 Dic 2009 (ok)<br />Set Inline input with datepicker: 24 Dic 2009 (ok)<br />serializeRowData: function (postada) postdata.espdate: 24 Dic 2009 (ok??, The data in postdata should be in srcformat or option for it?)<br />espdate POST: 2009-12-24 (ok, after parse function ig_sqlDate(postdata.espdate))<br />Grid after post: 2009-12-24 (not ok)</p>
<p>Suggested sequence:</p>
<p>Inline input: 15 Dic 2009<br />Set Inline input with datepicker: 24 Dic 2009<br />serializeRowData: function (postada) postdata.espdate: 2009-12-24<br />Grid after post: 24 Dic 2009</p>
<p>Or postada is independent of data to show in grid,<br />Or postdata in srcformat, data to show in grid in newformat,<br />Or workaround: editRow(rowid, true, &#39;&#39;, &#39;&#39;, &#39;&#39;,&#39;&#39;,aftersavefunc) cumbersome with multiple grids</p>
<p>Other options?</p>
<p>Best regards,</p>
]]></description>
        	        	<pubDate>Wed, 18 Nov 2009 05:53:40 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Inline edit: rowid update &#38; dates</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates#p12048</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates#p12048</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>This is true, we post what is putted and your way is right.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Tue, 17 Nov 2009 02:36:27 +0200</pubDate>
        </item>
        <item>
        	<title>ignrac on Inline edit: rowid update &#38; dates</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates#p11975</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/inline-edit-rowid-update-dates#p11975</guid>
        	        	<description><![CDATA[<p>Using the next grid:</p>
<p>var lastsel;<br />Query("#grid0").jqGrid({<br />&#160;&#160;&#160; url:url_get,<br />&#160;&#160;&#160; datatype: "xml",<br />&#160;&#160;&#160; colNames:[jq_cols[0].col_caption,jq_cols[0].col_caption],<br />&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;espcode&#39;,index:&#39;espcode&#39;, width:64, <strong>key:true</strong>, editable:true, align:"right",editoptions: {size:3, maxlength: 3}},<br />&#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;espname&#39;,index:&#39;espname&#39;, width:210,editable:true,editoptions: {size:38, maxlength: 40}}<br />&#160;&#160;&#160; &#160;&#160;&#160; ],<br />&#160;&#160;&#160; rowNum:jq_numrows,<br />&#160;&#160;&#160; autowidth : true,<br />&#160;&#160;&#160; shrinkToFit: false,<br />&#160;&#160;&#160; scrollOffset: 0,<br />&#160;&#160;&#160; gridview: true,<br />&#160;&#160;&#160; pager: jQuery(&#39;#pager&#39;),<br />&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160;&#160; onSelectRow: function(id){<br />&#160;&#160;&#160; &#160;&#160;&#160; if(id &#38;&#38; id!==lastsel){<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; jQuery(&#39;#grid0&#39;).restoreRow(lastsel);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; jQuery(&#39;#grid0&#39;).editRow(id,true);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; lastsel=id;<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; },<br />&#160;&#160;&#160; gridComplete: function() {<br />&#160;&#160;&#160; &#160;&#160;&#160; lastsel=undefined;<br />&#160;&#160;&#160; },<br />&#160;&#160;&#160; height:jq_numrows * jq_hr,<br />&#160;&#160;&#160; hidegrid: false,<br />&#160;&#160;&#160; editurl:url_post,<br />&#160;&#160;&#160; caption: jq_grid[0].caption,<br />&#160;&#160;&#160; loadui:"block"<br />});</p>
<p>I use the post id as parameter to select the record data on a server (where id=&#39;x&#39;).<br />The problem occurs when the data has been published in the column whose ColModel key:true, it is not updated<br />the rowid. Subsequent editions keep the id of the last reading, for example:</p>
<p>Data read:<br />id: C50<br />espcode: C50<br />espname: Users</p>
<p>First edit:<br />Grid -&#62; Post<br />id: C50 -&#62; C50<br />espcode: C50 -&#62; U60<br />espname: Users -&#62; Users</p>
<p>update table SET espcode = &#39;U60&#39;, espname = &#39;Users&#39; WHERE espcode = &#39;C50&#39; (ok)</p>
<p>Second edit:<br />Grid -&#62; Post<br />id: C50 -&#62; C50<br />espcode: U60 -&#62; C70<br />espname: Users -&#62; Users</p>
<p>update table SET espcode = &#39;C70&#39;, espname = &#39;Users&#39; WHERE espcode = &#39;C50&#39; (not ok, espcode = &#39;C50&#39; not exist)</p>
<p>The possible solution I&#39;ve found is to run jQuery(&#39;#grid0&#39;).trigger(&#39;reloadGrid&#39;), in a function <br />within the parameter aftersavefunc of editRow function, to reload ID&#39;s:</p>
<p>jQuery(&#39;#grid0&#39;).editRow(id,true,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,jq_reload);</p>
<p>function jq_reload(id, res){<br />&#160;&#160;&#160; if (res.statusText != &#39;OK&#39;) alert(jq_serverXHR(res));<br />&#160;&#160;&#160; jQuery(&#39;#grid0&#39;).trigger(&#39;reloadGrid&#39;);<br />}</p>
<p>Now with 3.6, I can use serializeRowData to add a value with data of rowid on last edit:</p>
<p>var rowKey;<br />var lastsel;<br />Query("#grid0").jqGrid({<br />&#160;&#160;&#160; url:url_get,<br />&#160;&#160;&#160; datatype: "xml",<br />&#160;&#160;&#160; colNames:[jq_cols[0].col_caption,jq_cols[0].col_caption],<br />&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;espcode&#39;,index:&#39;espcode&#39;, width:64, key:true, editable:true, align:"right",editoptions: {size:3, maxlength: 3}},<br />&#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;espname&#39;,index:&#39;espname&#39;, width:210,editable:true,editoptions: {size:38, maxlength: 40}}<br />&#160;&#160;&#160; &#160;&#160;&#160; ],<br />&#160;&#160;&#160; rowNum:jq_numrows,<br />&#160;&#160;&#160; autowidth : true,<br />&#160;&#160;&#160; shrinkToFit: false,<br />&#160;&#160;&#160; scrollOffset: 0,<br />&#160;&#160;&#160; gridview: true,<br />&#160;&#160;&#160; pager: jQuery(&#39;#pager&#39;),<br />&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160;&#160; serializeRowData:function(postdata) {<br />&#160;&#160;&#160; &#160;&#160;&#160; postdata.rowKey = rowKey;<br />&#160;&#160;&#160; &#160;&#160;&#160; return postdata;<br />&#160;&#160;&#160; },<br />&#160;&#160;&#160; onSelectRow: function(id){<br />&#160;&#160;&#160; &#160;&#160;&#160; if(id &#38;&#38; id!==lastsel){<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; jQuery(&#39;#grid0&#39;).restoreRow(lastsel);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; rowData = jQuery(&#39;#grid0&#39;).getRowData(id);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; rowKey = rowData.espdate;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; jQuery(&#39;#grid0&#39;).editRow(id,true);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; lastsel=id;<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; },<br />&#160;&#160;&#160; gridComplete: function() {<br />&#160;&#160;&#160; &#160;&#160;&#160; rowKey = undefined;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; lastsel= undefined;<br />&#160;&#160;&#160; },<br />&#160;&#160;&#160; height:jq_numrows * jq_hr,<br />&#160;&#160;&#160; hidegrid: false,<br />&#160;&#160;&#160; editurl:url_post,<br />&#160;&#160;&#160; caption: jq_grid[0].caption,<br />&#160;&#160;&#160; loadui:"block"<br />});</p>
<p>The problem: <br />The edited postdata in serializeRowData, show in grid.</p>
<p>I use a grid with a key column with date formatter:</p>
<p>&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;espdate&#39;,index:&#39;espdate&#39;, width:64, key:true, editable:true, align:"right",<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; formatter:&#39;date&#39;, formatoptions:{srcformat:"Y-m-d",newformat:"j M Y"},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; editoptions: {size:12, dataInit:function(el){$(el).datepicker({dateFormat:&#39;d M yy&#39;,minDate: &#39;+1&#39;, maxDate: jq_grids[&#39;#grid0&#39;].maxDate ,onClose: function(){<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; $(this).focus();},changeMonth: true});}, readonly:&#39;readonly&#39;}},<br />&#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;espname&#39;,index:&#39;espname&#39;, width:210,editable:true,editoptions: {size:38, maxlength: 40}}<br />&#160;&#160;&#160; &#160;&#160;&#160; ],</p>
<p>I use the datepicker parse function (in a function) for post date in SQL format:</p>
<p>&#160;&#160;&#160; serializeRowData:function(postdata) {<br />&#160;&#160;&#160; &#160;&#160;&#160; postdata.espdate = ig_sqlDate(postdata.espdate);<br />&#160;&#160;&#160; &#160;&#160;&#160; postdata.rowKey = ig_sqlDate(rowKey);<br />&#160;&#160;&#160; &#160;&#160;&#160; return postdata;<br />&#160;&#160;&#160; },</p>
<p>If i use unformat option in colModel, getRowData retrieve data in srcformat, but inline edit post data in newformat.</p>
]]></description>
        	        	<pubDate>Mon, 16 Nov 2009 04:56:20 +0200</pubDate>
        </item>
</channel>
</rss>