<?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: Added row's ID for refresh</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh</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/added-rows-id-for-refresh/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Steffan on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22289</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22289</guid>
        	        	<description><![CDATA[<p>Oleg,</p>
<p>Thank you so much!!</p>
<p>For the record, if anyone else gets stuck and this is Google indexed, here is the final constructor!</p>
<p>$("#navgrid").jqGrid({</p>
<p>url:appendSession("/async/users.lasso?x=1"),</p>
<p>datatype: "json",</p>
<p>hidegrid: false,</p>
<p>colNames:["User ID","First Name","Last Name","Email","Password","Groups","Notes","Admin"],</p>
<p>colModel:[</p>
<p>{name:&#39;id&#39;,			index:&#39;userid&#39;, 		width:55,	editable:false,	editoptions:{readonly:true,size:10}, hidden:true},</p>
<p>{name:&#39;firstname&#39;,	index:&#39;firstname&#39;, 	width:100,	editable:true,	editoptions:{size:25}, 	editrules:{required:true}, resizable:true},</p>
<p>{name:&#39;lastname&#39;,	index:&#39;lastname&#39;, 	width:100,	editable:true,	editoptions:{size:25}, 	editrules:{required:true}, resizable:true},</p>
<p>{name:&#39;email&#39;,		index:&#39;email&#39;, 		width:200, 	editable:true,	editoptions:{size:25}, 	editrules:{email:true, required:true}, resizable:true},</p>
<p>{name:&#39;password&#39;,	index:&#39;password&#39;, 	width:100, 	editable:true,	editoptions:{size:25},	editrules:{edithidden:true}, hidden:true, resizable:true },</p>
<p>{name:&#39;groups&#39;,		index:&#39;groups&#39;, 	width:260,	editable:true,	edittype:"select",		editoptions:{	multiple:true, size:3,</p>
<p>value: $.parseJSON( $.ajax({ url: appendSession(&#39;/async/groups.lasso&#39;), type:&#39;post&#39;, data: { x:1 }, dataType: &#39;json&#39;, async: false, success: function(data, result) { if (!result) alert(&#39;Failure to retrieve the groups.&#39;); } }).responseText)</p>
<p>},</p>
<p>sortable:false, resizable:true},</p>
<p>{name:&#39;notes&#39;,		index:&#39;notes&#39;, 		width:10,	editable:true,	edittype:"textarea",	editrules:{edithidden:true}, hidden:true, editoptions:{rows:"3",cols:"26"}, sortable:false},</p>
<p>{name:&#39;isadmin&#39;,	index:&#39;isadmin&#39;,	width:60,	editable:true,	edittype:"checkbox", 	editoptions:{value:"Yes:No"}, align:"center" }</p>
<p>],</p>
<p>rowNum:10,</p>
<p>rowList:[10,20,30],</p>
<p>pager: &#39;#pagernav&#39;,</p>
<p>sortname: "userid",</p>
<p>viewrecords: true,</p>
<p>sortorder: "desc",</p>
<p>caption:"Users Management",</p>
<p>editurl:appendSession("/async/users.lasso?x=2"),</p>
<p>height:210</p>
<p>});</p>
<p>$("#navgrid").jqGrid(&#39;navGrid&#39;,&#39;#pagernav&#39;,</p>
<p>{}, //options</p>
<p>{height:325,reloadAfterSubmit:false,closeAfterEdit:true,closeOnEscape:true}, // edit options</p>
<p>{height:325,reloadAfterSubmit:false,closeAfterAdd:true,closeOnEscape:true, afterSubmit: function(response,postdata) { return [true,"",response.responseText]; } }, // add options</p>
<p>{reloadAfterSubmit:false,closeOnEscape:true}, // del options</p>
<p>{closeOnEscape:true} // search options</p>
<p>);</p></p>
]]></description>
        	        	<pubDate>Thu, 03 Mar 2011 04:29:34 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22274</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22274</guid>
        	        	<description><![CDATA[<p>I supose the error is in my previous code. The <strong>afterSubmit</strong> should be:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3244' value='Select Code' data-codeid='sfcode3244' /></p>
<div class='sfcode' id='sfcode3244'>afterSubmit: function(response,postdata) {<br />&#160;&#160; &#160;return [true,&#34;&#34;,response.responseText];<br />}</div>
<p>Best regards<br />Oleg</p>
]]></description>
        	        	<pubDate>Wed, 02 Mar 2011 08:33:53 +0200</pubDate>
        </item>
        <item>
        	<title>Steffan on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22273</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22273</guid>
        	        	<description><![CDATA[<p>Well, we&#39;re getting closer. Its odd. This is what the row looks like inthe Safari element inspector</p>
</p>
<p>&#60;tr id="[object XMLHttpRequest]" role="row" class="ui-widget-content jqgrow ui-row-ltr  ui-state-highlight ui-state-hover" aria-selected="true"&#62;&#60;td role="gridcell" aria-describedby="navgrid_id" style="display:none;" title="[object XMLHttpRequest]"&#62;[object XMLHttpRequest]&#60;/td&#62;&#60;td role="gridcell" aria-describedby="navgrid_firstname" style="" title="george"&#62;george&#60;/td&#62;&#60;td role="gridcell" aria-describedby="navgrid_lastname" style="" title="lopez"&#62;lopez&#60;/td&#62;&#60;td role="gridcell" aria-describedby="navgrid_email" style="" title="george@lopez.com"&#62;george@lopez.com&#60;/td&#62;&#60;td role="gridcell" aria-describedby="navgrid_password" style="display:none;" title="fsfsdfs"&#62;fsfsdfs&#60;/td&#62;&#60;td role="gridcell" aria-describedby="navgrid_groups" style="" title="Group 1,Group 2,Group 3,Group 4,Group 5,Group 6,Group 7,Group 8"&#62;Group 1,Group 2,Group 3,Group 4,Group 5,Group 6,Group 7,Group 8&#60;/td&#62;&#60;td role="gridcell" aria-describedby="navgrid_notes" style="display:none;" title="test"&#62;test&#60;/td&#62;&#60;td role="gridcell" aria-describedby="navgrid_isadmin" style="text-align:center;" title="Yes"&#62;Yes&#60;/td&#62;&#60;/tr&#62;</p>
</p>
<p>Notice what the id is. Did I make a mistake in there? I implented the code as you suggested. I don&#39;t see a section on the afterSubmit in detail within the wiki to understand the &#160;return [true,"",responseText]; Below is my constructor with your addition.</p>
</p>
<p>$("#navgrid").jqGrid({</p>
<p>url:appendSession("/async/users.lasso?x=1"),</p>
<p>datatype: "json",</p>
<p>hidegrid: false,</p>
<p>colNames:["User ID","First Name","Last Name","Email","Password","Groups","Notes","Admin"],</p>
<p>colModel:[</p>
<p>{name:&#39;id&#39;,			index:&#39;userid&#39;, 		width:55,	editable:false,	editoptions:{readonly:true,size:10}, hidden:true},</p>
<p>{name:&#39;firstname&#39;,	index:&#39;firstname&#39;, 	width:100,	editable:true,	editoptions:{size:25}, 	editrules:{required:true}, resizable:true},</p>
<p>{name:&#39;lastname&#39;,	index:&#39;lastname&#39;, 	width:100,	editable:true,	editoptions:{size:25}, 	editrules:{required:true}, resizable:true},</p>
<p>{name:&#39;email&#39;,		index:&#39;email&#39;, 		width:200, 	editable:true,	editoptions:{size:25}, 	editrules:{email:true, required:true}, resizable:true},</p>
<p>{name:&#39;password&#39;,	index:&#39;password&#39;, 	width:100, 	editable:true,	editoptions:{size:25},	editrules:{edithidden:true}, hidden:true, resizable:true },</p>
<p>{name:&#39;groups&#39;,		index:&#39;groups&#39;, 	width:260,	editable:true,	edittype:"select",		editoptions:{	multiple:true, size:3,</p>
<p>value: $.parseJSON( $.ajax({ url: appendSession(&#39;/async/groups.lasso&#39;), type:&#39;post&#39;, data: { x:1 }, dataType: &#39;json&#39;, async: false, success: function(data, result) { if (!result) alert(&#39;Failure to retrieve the groups.&#39;); } }).responseText)</p>
<p>},</p>
<p>sortable:false, resizable:true},</p>
<p>{name:&#39;notes&#39;,		index:&#39;notes&#39;, 		width:10,	editable:true,	edittype:"textarea",	editrules:{edithidden:true}, hidden:true, editoptions:{rows:"3",cols:"26"}, sortable:false},</p>
<p>{name:&#39;isadmin&#39;,	index:&#39;isadmin&#39;,	width:60,	editable:true,	edittype:"checkbox", 	editoptions:{value:"Yes:No"}, align:"center" }</p>
<p>],</p>
<p>rowNum:10,</p>
<p>rowList:[10,20,30],</p>
<p>pager: &#39;#pagernav&#39;,</p>
<p>sortname: "userid",</p>
<p>viewrecords: true,</p>
<p>sortorder: "desc",</p>
<p>caption:"Users Management",</p>
<p>editurl:appendSession("/async/users.lasso?x=2"),</p>
<p>height:210</p>
<p>});</p>
<p>$("#navgrid").jqGrid(&#39;navGrid&#39;,&#39;#pagernav&#39;,</p>
<p>{}, //options</p>
<p>{height:325,reloadAfterSubmit:false,closeAfterEdit:true,closeOnEscape:true}, // edit options</p>
<p>{height:325,reloadAfterSubmit:false,closeAfterAdd:true,closeOnEscape:true, afterSubmit: function(responseText,postdata) { return [true,"",responseText]; } }, // add options</p>
<p>{reloadAfterSubmit:false,closeOnEscape:true}, // del options</p>
<p>{closeOnEscape:true} // search options</p>
<p>);</p></p>
]]></description>
        	        	<pubDate>Wed, 02 Mar 2011 08:07:20 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22266</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22266</guid>
        	        	<description><![CDATA[<p>OK Steffan,</p>
<p>The datatype:&#39;json&#39; is not really important for the form editing which you use. Insetad of that the method <strong>afterSubmit</strong> is what you need to implement because you use&#160;<strong>reloadAfterSubmit:false</strong> option. You server have to return the id of new created row in any form want you will. In the simplest situation the server component, which are accessble under the <strong>editurl</strong> "/async/users.lasso?x=2&#8243;&#160;which you use, can just return the string 1234 without any quotes as the result of "Add" operations. On "Delele" or "Edit" operation it should return empty body (empty string). Then your version of the&#160;<strong>afterSubmit</strong>&#160;function can be</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6672' value='Select Code' data-codeid='sfcode6672' /></p>
<div class='sfcode' id='sfcode6672'>afterSubmit: function(responseText,postdata) {<br />&#160;&#160; &#160;return [true,&#34;&#34;,responseText];<br />}</div>
<p>In the case you will use the text from the server response as the id of the new row. You can set the afterSubmit for all grids with respect of</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5803' value='Select Code' data-codeid='sfcode5803' /></p>
<div class='sfcode' id='sfcode5803'>jQuery.extend(jQuery.jgrid.edit,<br />&#160;&#160; &#160;{<br />&#160;&#160; &#160; &#160; &#160;reloadAfterSubmit:false,<br />&#160;&#160; &#160; &#160; &#160;closeAfterAdd:true,<br />&#160;&#160; &#160; &#160; &#160;closeAfterEdit:true,<br />&#160;&#160; &#160; &#160; &#160;closeOnEscape:true,<br />&#160;&#160; &#160; &#160; &#160;afterSubmit: function (responseText, postdata) {<br />&#160;&#160; &#160; &#160; &#160; &#160; &#160;return [true,&#34;&#34;,responseText];<br />&#160;&#160; &#160; &#160; &#160;}<br />&#160;&#160; &#160;}<br />);</div>
<p>Best regards<br />Oleg&#160;</p>
]]></description>
        	        	<pubDate>Tue, 01 Mar 2011 21:48:16 +0200</pubDate>
        </item>
        <item>
        	<title>Steffan on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22264</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22264</guid>
        	        	<description><![CDATA[<p>Oleg,</p>
<p>I&#39;ve searched the documentation a few times and I&#39;m not seeing any examples of how the data has to be formatted when returning the new ID back to the plugin. Do you have an example? Should it be JSON since I am using datatype: &#39;json&#39; ? Should it be in the form of {id:1234}?</p>
<p>Thanks,<br />Steffan</p>
]]></description>
        	        	<pubDate>Tue, 01 Mar 2011 20:52:15 +0200</pubDate>
        </item>
        <item>
        	<title>Steffan on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22247</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22247</guid>
        	        	<description><![CDATA[<p>I&#39;m stuck. Any suggestions?</p>
]]></description>
        	        	<pubDate>Mon, 28 Feb 2011 22:26:55 +0200</pubDate>
        </item>
        <item>
        	<title>Steffan on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22241</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22241</guid>
        	        	<description><![CDATA[<p>This is my current constructor:</p>
<p>$("#navgrid").jqGrid({</p>
<p>url:appendSession("/async/users.lasso?x=1"),</p>
<p>datatype: "json",</p>
<p>hidegrid: false,</p>
<p>colNames:["User ID","First Name","Last Name","Email","Password","Groups","Notes","Admin"],</p>
<p>colModel:[</p>
<p>{name:&#39;id&#39;,			index:&#39;userid&#39;, 		width:55,	editable:false,	editoptions:{readonly:true,size:10}, hidden:true},</p>
<p>{name:&#39;firstname&#39;,	index:&#39;firstname&#39;, 	width:100,	editable:true,	editoptions:{size:25}, 	editrules:{required:true}, resizable:true},</p>
<p>{name:&#39;lastname&#39;,	index:&#39;lastname&#39;, 	width:100,	editable:true,	editoptions:{size:25}, 	editrules:{required:true}, resizable:true},</p>
<p>{name:&#39;email&#39;,		index:&#39;email&#39;, 		width:200, 	editable:true,	editoptions:{size:25}, 	editrules:{email:true, required:true}, resizable:true},</p>
<p>{name:&#39;password&#39;,	index:&#39;password&#39;, 	width:100, 	editable:true,	editoptions:{size:25},	editrules:{edithidden:true}, hidden:true, resizable:true },</p>
<p>{name:&#39;groups&#39;,		index:&#39;groups&#39;, 	width:260,	editable:true,	edittype:"select",		editoptions:{	multiple:true, size:3,</p>
<p>value: $.parseJSON( $.ajax({ url: appendSession(&#39;/async/groups.lasso&#39;), type:&#39;post&#39;, data: { x:1 }, dataType: &#39;json&#39;, async: false, success: function(data, result) { if (!result) alert(&#39;Failure to retrieve the groups.&#39;); } }).responseText)</p>
<p>},</p>
<p>sortable:false, resizable:true},</p>
<p>{name:&#39;notes&#39;,		index:&#39;notes&#39;, 		width:10,	editable:true,	edittype:"textarea",	editrules:{edithidden:true}, hidden:true, editoptions:{rows:"3",cols:"26"}, sortable:false},</p>
<p>{name:&#39;isadmin&#39;,	index:&#39;isadmin&#39;,	width:60,	editable:true,	edittype:"checkbox", 	editoptions:{value:"Yes:No"}, align:"center" }</p>
<p>],</p>
<p>rowNum:10,</p>
<p>rowList:[10,20,30],</p>
<p>pager: &#39;#pagernav&#39;,</p>
<p>sortname: "userid",</p>
<p>viewrecords: true,</p>
<p>sortorder: "desc",</p>
<p>caption:"Users Management",</p>
<p>editurl:appendSession("/async/users.lasso?x=2"),</p>
<p>height:210</p>
<p>});</p>
<p>$("#navgrid").jqGrid(&#39;navGrid&#39;,&#39;#pagernav&#39;,</p>
<p>{}, //options</p>
<p>{height:325,reloadAfterSubmit:false,closeAfterEdit:true,closeOnEscape:true}, // edit options</p>
<p>{height:325,reloadAfterSubmit:false,closeAfterAdd:true,closeOnEscape:true}, // add options</p>
<p>{reloadAfterSubmit:false,closeOnEscape:true}, // del options</p>
<p>{closeOnEscape:true} // search options</p>
<p>);</p>
<p>&#160;Is there something I need to add into the add options to attach the new ID to the table?</p>
]]></description>
        	        	<pubDate>Mon, 28 Feb 2011 15:33:28 +0200</pubDate>
        </item>
        <item>
        	<title>Steffan on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22240</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22240</guid>
        	        	<description><![CDATA[<p>Using trial and error I found that if I wanted to use "userid" I&#39;d have to change the parameters in my grid constructor. I&#39;ve changed my code on the backend to just use whatever your plugin sends. I have all that working fine. My question is what do I need to have the server send back to the client? Currently, I have the server sending back the id of the newly created record. For example id:1234 etc. So, what do I need to do on the client (browser) side to grab the new ID and insert it into the table? Will your jsonReader example do that?</p>
<p>Thanks,<br />Steffan&#160;</p>
]]></description>
        	        	<pubDate>Mon, 28 Feb 2011 15:26:24 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22236</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22236</guid>
        	        	<description><![CDATA[<p>Just now mention, that in the previous question with JSON data you used "userid" instead of "id". Do you used <strong>jsonReader:{id:&#39;userid&#39;}</strong> parameter? I updated <a href="http://www.ok-soft-gmbh.com/jqGrid/Steffan2-json.htm" rel="nofollow" target="_blank"><a href="http://www.ok-soft-gmbh.com/jq" rel="nofollow">http://www.ok-soft-gmbh.com/jq</a>.....2-json.htm</a>.</p>
<p>You should verity in IE Developer Tools or in Firebug which ids has &#60;tr&#62; elements and which hes new added row. The correct response from the server on "add" operation should be the id of the new row. Is it so in your grid?</p>
<p>Best regards<br />Oleg&#160;</p></p>
]]></description>
        	        	<pubDate>Mon, 28 Feb 2011 08:39:52 +0200</pubDate>
        </item>
        <item>
        	<title>Steffan on Added row's ID for refresh</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22235</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/added-rows-id-for-refresh#p22235</guid>
        	        	<description><![CDATA[<p>Is there some kind of call back or something that I misssed where I pass some sort of response with the ID of the newly added row back to the browser so that if its edited after being added and the browser not refreshed I don&#39;t get an error? I know I can use the reloadAfterSubmit:true but it seems there has to be a better way to do it. I looked through the examples and didn&#39;t see it.</p>
<p>add row -&#62; server -&#62; add record -&#62; return new id to browser -&#62; browser updates table with new row ID.&#160;</p>
<p>Suggestions?</p>
<p>Thanks,<br />Steffan&#160;</p>
]]></description>
        	        	<pubDate>Mon, 28 Feb 2011 06:39:31 +0200</pubDate>
        </item>
</channel>
</rss>