<?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: How can the key name 'id' be changed in saveRow()</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow</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/how-can-the-key-name-id-be-changed-in-saverow/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>jnavratil on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5467</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5467</guid>
        	        	<description><![CDATA[<p>So, I guess option (1) is it.&#160; I will prefix all my data with &#39;xx&#39; and hope jqGrid never uses a key beginning with &#39;xx&#39;.</p>
<p>Still it seems asymmetric as the jsonReader requires a separation of the &#39;id&#39; from the &#39;cell&#39; data.&#160; It just doesn&#39;t work that way when writing.</p>
<p>Still, it&#39;s a great plugin!&#160; Thanks!</p>
]]></description>
        	        	<pubDate>Fri, 20 Mar 2009 12:39:55 +0200</pubDate>
        </item>
        <item>
        	<title>jnavratil on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5398</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5398</guid>
        	        	<description><![CDATA[<p>Tony,</p>
<p>I added the { key : true } to my colModel object for my key column giving...</p>
<p>{ name: &#39;invid&#39;, index: &#39;invid&#39;, editable: false, key: true, width: 66, align: &#39;right&#39; }</p>
<p>... and reran my test with a non-key column named &#39;id&#39; (not the primary key).&#160; The results were the same.&#160; The POST array had an &#39;id&#39; key with the primary key in it.&#160; There was no &#39;invid&#39; key.</p>
<p>Did I understand your suggestion correctly?</p>
<p>Thanks,</p>
<p>-- JOhn</p></p>
]]></description>
        	        	<pubDate>Tue, 17 Mar 2009 08:57:25 +0200</pubDate>
        </item>
        <item>
        	<title>tony on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5388</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5388</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Maybe you should try with the option key:true too, which have higger priority.</p>
</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Tue, 17 Mar 2009 01:55:56 +0200</pubDate>
        </item>
        <item>
        	<title>jnavratil on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5378</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5378</guid>
        	        	<description><![CDATA[<p>Hello, Tony!</p>
<p>I do understand what you are saying. I have already used the extra parameters to communicate both the table name and primary column name.&#160; The problem is purely in the collision between the jqGrid use of the &#39;id&#39; keyword for the primary key value and a database column of the same name.</p>
<p>Here is an example using the &#39;invheader&#39; test table.&#160; My saveRow() code is...</p>
<p>jQuery(gridName).saveRow(rowID, &#39;&#39;, &#39;tableEditor.php&#39;,</p>
<p>&#160;&#160;&#160; { jqGridOp : &#39;updateRow&#39;, jqGridTable : tableName, jqGridUIDCol : UIDColumnName },<br />&#160;&#160;&#160; aftersavefunc);</p>
<p>saveRow() generates a POST array which looks like<br />{"invdate"=&#62;"2009-02-10", "client_id"=&#62;"10", "amount"=&#62;"123.45", "tax"=&#62;"10.11", "total"=&#62;"133.56", "note"=&#62;"Test 1", "id"=&#62;"1", "jqGridOp"=&#62;"updateRow", "jqGridTable"=&#62;"invheader", "jqGridUIDCol"=&#62;"invid"}</p>
<p>So I use my &#39;jqGridUIDCol&#39; as the name of the primary key column and the &#39;id&#39; column as its value.&#160; Problem solved as long as there is no other column in the table with the name &#39;id&#39;.&#160; If I change the name of the &#39;client_id&#39; column in the database to &#39;id&#39; and my jsonReader to</p>
<p>jsonReader: {<br />&#160;&#160;&#160; root: &#39;rows&#39;,<br />&#160;&#160;&#160; page: &#39;page&#39;,<br />&#160;&#160;&#160; total: &#39;total&#39;,<br />&#160;&#160;&#160; records: &#39;records&#39;,<br />&#160;&#160;&#160; repeatitems: true,<br />&#160;&#160;&#160; cell: &#39;cell&#39;,<br />&#160;&#160;&#160; id: &#39;jqGridUIDVal&#39;<br />},</p>
<p>The POST array generated by saveRow is {"invdate"=&#62;"2009-02-10", "id"=&#62;"1", "amount"=&#62;"123.45", "tax"=&#62;"10.11", "total"=&#62;"133.56", "note"=&#62;"Test 1", "jqGridOp"=&#62;"updateRow", "jqGridTable"=&#62;"invheader", "jqGridUIDCol"=&#62;"invid"}.</p>
<p>Notice that there are now only 9 elements in the array.&#160; The &#39;id&#39; column again contains the primary key value, but the value for the non-key &#39;id&#39; column (the one which was &#39;client_id&#39;) is lost because of the name collision.</p>
<p>I can see several ways to work around this.</p>
<p>(1) Modify the server code to detect and avoid conflicting names.&#160; PRO - no change to jqGrid.&#160; CON - must know all keywords (&#39;oper&#39;, for example) used during an update or insert operation (the $exclusions) and change server code if jqGrid changes.</p>
<p>(2) Modify jqGrid to reference a keywords object when generating the GET/POST data which could be rewritten by the user if needed.&#160; For example</p>
<p>var keywords {jqGridID : "id", jqGridOper : "oper"...};</p>
<p>PRO - no change to installed code.&#160; Only minor modifications to jqGrid. All keywords are present in an object which can be transmitted to the server for exclusion handling.&#160; CON - Modifications to jqGrid needed.</p>
<p>(3) Add a rowset (or other) keyword to contain all the row col/value pairs.&#160; Leave other keywords/values as currently generated and deprecate.</p>
<p>PRO - complete separation of namespaces between rowset data and metadata. Existing code only lightly affected (must know to ignore the &#39;rowset&#39; keyword).&#160; Once converted, server code is more effectively separated from jqGrid.&#160; CON - existing code may be affected.&#160; More substantial code change to jqGrid.&#160; Not as simple an interface to the server.</p>
<p>IMHO, choice (3) is the best.&#160; Choice (2) does provide enough data to be able to detect the problem and a means for an easy work-around.</p>
<p>Thanks!</p>
<p>-- John</p>
]]></description>
        	        	<pubDate>Mon, 16 Mar 2009 12:23:58 +0200</pubDate>
        </item>
        <item>
        	<title>tony on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5367</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5367</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Before edit the row get the id of the column - let say myid, then</p>
<p>myextraparam = {jqGridUIDCol:myid}</p>
<p>$("#mygrid").saveRow(myid, false, myurl, myextraparam);</p>
<p>When you post the value from jqgrid use&#160; jqGridUIDCol instead of id</p>
<p>Hope this helps</p>
<p>REgards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 16 Mar 2009 06:11:45 +0200</pubDate>
        </item>
        <item>
        	<title>jnavratil on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5340</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5340</guid>
        	        	<description><![CDATA[<p>Tony,</p>
<p>The problem is that if I have a table with a column named &#39;id&#39;, that column cannot be edited.&#160; Generally, speaking the POST data sent to the server in insert and update are the column names and their values, but anything jqGrid adds to this data(&#39;id&#39;, e.g.) is added into the same namespace where collision is possible and special handling is required as indicated by the $exceptions list of fields in the server.php example.</p>
<p>For specific tables where &#39;id&#39; is a column name, special handling at the server could select &#39;id&#39; as somethingElse but it seems a more general solution is to separate these name spaces.</p>
<p>One possibility is to send only two variables via Ajax; the row data and other meta-data.&#160; Or, perhaps, to put all row data into a json string or XML document and pass it as a single variable.</p>
<p>In this way, jqGrid would never have a conflict with a column name.&#160; Do you agree?</p>
<p>Thanks!</p>
<p>-- John</p>
]]></description>
        	        	<pubDate>Fri, 13 Mar 2009 15:14:46 +0200</pubDate>
        </item>
        <item>
        	<title>tony on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5327</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5327</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>IMHO this solution is not applicable. One approach is to create a hidden coulmn and post it. Another is to use the extraparam to pass additional data to the post.</p>
<p>See docs</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Fri, 13 Mar 2009 10:21:47 +0200</pubDate>
        </item>
        <item>
        	<title>jnavratil on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5325</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5325</guid>
        	        	<description><![CDATA[<p>Tony,</p>
<p>I was able to achieve my desired result by changing line 122 of grid.inlinedit.js (should that name be inlineedit?) from...</p>
<p>if(tmp) { tmp["id"] = rowid; ....</p>
<p>to</p>
<p>if(tmp) { tmp[$t.p.jsonReader.id] = rowid; ....</p>
<p>but I don&#39;t think this is a real solution as it relies on the presence of the jsonReader object.&#160; Still, something like this is needed to get rid of the magic &#39;id&#39;, don&#39;t you think?&#160; Perhaps a test for a name before defaulting to &#39;id&#39;?</p>
<p>-- John</p>
]]></description>
        	        	<pubDate>Fri, 13 Mar 2009 10:11:23 +0200</pubDate>
        </item>
        <item>
        	<title>jnavratil on How can the key name 'id' be changed in saveRow()</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5315</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-can-the-key-name-id-be-changed-in-saverow#p5315</guid>
        	        	<description><![CDATA[<p>I am writing a generic table editor for browsing my database.&#160; My convention is to create primary key names using the table name (Users_UID, for example) and &#39;id&#39; can be a column name of no particular interest.&#160; When I call saveRow, I pass additional parametric data including the name of the primary key field which changes from table to table.</p>
<p>Obviously this parametric data cannot collide with column names of the table so I choose keys named &#39;jqGridTable&#39;, &#39;jqGridUIDCol&#39;, etc. which I keep as reserved words.&#160; In my jsonReader parameter to jqGrid I coded</p>
<p>id : &#39;jqGridUIDCol&#39;</p>
<p>in hopes that this value would be used as the key into $_POST.&#160; It works reading, but no writing.</p>
<p>How can the output key name be changed so that saveRow emits $_POST[&#39;jqGridUIDCol&#39;] instead of $_POST[&#39;id&#39;] ?</p>
]]></description>
        	        	<pubDate>Fri, 13 Mar 2009 08:58:16 +0200</pubDate>
        </item>
</channel>
</rss>