<?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: custom_element not firing setter on every edit request</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/custom_element-not-firing-setter-on-every-edit-request</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/custom_element-not-firing-setter-on-every-edit-request/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>akitson on custom_element not firing setter on every edit request</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom_element-not-firing-setter-on-every-edit-request#p19443</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom_element-not-firing-setter-on-every-edit-request#p19443</guid>
        	        	<description><![CDATA[<p>I have a grid on which I need to populate the edit form with data fetched from the server for one particular element.&#160; The grid constructor is:</p>
<blockquote>
<p>jQuery("#dataList").jqGrid({<br />&#160;&#160; &#160;&#160;&#160; &#160;url:&#39;/input/getcamp?format=json&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;datatype: "json",<br />&#160;&#160; &#160;&#160;&#160; &#160;colNames:[&#39;Id&#39;,&#39;Name&#39;,&#39;Brand&#39;,&#39;Property&#39;,&#39;Attributes&#39;],<br />&#160;&#160; &#160;&#160;&#160; &#160;colModel:[<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;id&#39;,index:&#39;id&#39;, width:0,editable:false,hidden:true},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;cName&#39;,index:&#39;cName&#39;,editable:true,sortable:true,editrules:{required:true}},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;bName&#39;,index:&#39;bName&#39;,sortable:true,editable:true,edittype:"select",editoptions:{value:selBrand}},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;pName&#39;,index:&#39;pName&#39;,sortable:true,editable:true,edittype:"select",editoptions:{value:selProperty}},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;attribs&#39;,index:&#39;attribs&#39;,hidden:true,editable:true,edittype:&#39;custom&#39;,editoptions:{custom_element:_setCheckGroup,custom_value:_getCheckGroup},editrules:{edithidden:true}}<br />&#160;&#160; &#160;&#160;&#160; &#160;],<br />&#160;&#160; &#160;&#160;&#160; &#160;rowNum:10,<br />&#160;&#160; &#160;&#160;&#160; &#160;rowList:[10,20,30,40,50],<br />&#160;&#160; &#160;&#160;&#160; &#160;pager: &#39;#dataListPager&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;sortname: &#39;id&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;viewrecords: true,<br />&#160;&#160; &#160;&#160;&#160; &#160;sortorder: "desc",<br />&#160;&#160; &#160;&#160;&#160; &#160;caption:"Campaign Maintenance",<br />&#160;&#160; &#160;&#160;&#160; &#160;autowidth:true,<br />&#160;&#160; &#160;&#160;&#160; &#160;height:300,<br />&#160;&#160; &#160;&#160;&#160; &#160;scroll:true,<br />&#160;&#160; &#160;&#160;&#160; &#160;loadComplete:function(){gridOnLoad();},<br />&#160;&#160; &#160;&#160;&#160; &#160;onSelectRow:function(){showEditRowButton();}<br />&#160;&#160; &#160;});</p>
</blockquote>
<p>The custom functions are:</p>
<blockquote>
<p>//set up the attributes edit element in campaign edit<br />function _setCheckGroup(value, options) {<br />&#160;&#160; &#160;var cId = $("#dataList").jqGrid(&#39;getGridParam&#39;,&#39;selrow&#39;);<br />&#160;&#160; &#160;var t = $("#dataList").jqGrid();<br />&#160;&#160; &#160;var xhtml = &#39;&#39;;<br />&#160;&#160; &#160;var ele = document.createElement(&#39;rbAttribs&#39;);<br />&#160;&#160; &#160;$.ajax({url:&#39;/input/getattrib?format=json&#38;cId=&#39; + cId,<br />&#160;&#160; &#160;&#160;&#160; &#160;success:function(response){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(response.success) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;for (var x in response.data.allAttribs) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;xhtml += &#39;&#60;input type="checkbox" name="attribs" value="&#39; + x + &#39;"&#39;;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if (response.data.thisAttribs[x]) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;xhtml += &#39; checked&#39;;<br />&#160;&#160; &#160;&#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;xhtml += &#39; /&#62;&#39; + response.data.allAttribs[x]<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;$(ele).html(xhtml);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;} else {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;simplePopupMessage({title:"Oops!",message:response.msg,class:&#39;negative&#39;});<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;return false;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;},<br />&#160;&#160; &#160;&#160;&#160; &#160;cache:false,<br />&#160;&#160; &#160;&#160;&#160; &#160;async:false,<br />&#160;&#160; &#160;&#160;&#160; &#160;dataType:&#39;json&#39;<br />&#160;&#160; &#160;});<br />&#160;&#160; &#160;return ele;<br />}</p>
<p>//return value of edited attributes element from campaign edit<br />function _getCheckGroup(ele) {<br />&#160;&#160; &#160;var ret = &#39;&#39;;<br />&#160;&#160; &#160;$(ele + &#39;:checked&#39;).each(function(){<br />&#160;&#160; &#160;&#160;&#160; &#160;ret += $(this).val() + &#39;&#124;&#39;;<br />&#160;&#160; &#160;});<br />&#160;&#160; &#160;return ret.replace(/\&#124;$/,&#39;&#39;);<br />}</p>
</blockquote>
<p>recreateForm is set true in both the edit and add options for the forms</p>
<p>Now this all works fine the first time I edit a row, but for the second and subsequent edits, the _setCheckGroup() function is never called and therefore the contents of the check boxes is not updated from the server.&#160; How can I get the grid/form to call _setCheckGroup() every time I edit a row?</p></p>
]]></description>
        	        	<pubDate>Tue, 31 Aug 2010 18:13:06 +0300</pubDate>
        </item>
</channel>
</rss>