<?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 Checkbox</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/custom-checkbox</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-checkbox/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Rob on Custom Checkbox</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-checkbox#p25019</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-checkbox#p25019</guid>
        	        	<description><![CDATA[<p>Below is a custom formatter I have for a cell to place two checkboxes in a cell.&#160;&#160; &#160;</p>
<p>function myFormatter(cellvalue,options,rowObject)<br />&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;var regID="";<br />&#160;&#160; &#160;&#160;&#160; &#160;if (rowObject[0] == "undefined")<br />&#160;&#160; &#160;&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;regID = rowObject.regID&#160;&#160; &#160;;<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;else<br />&#160;&#160; &#160;&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;regID = rowObject[0];<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;var approval = $(&#39;#grid&#39;).getLocalRow(options.rowId).approvalSelect;<br />&#160;&#160; &#160;&#160;&#160; &#160;return &#39;&#60;input type="checkbox" id="checkBoxYes_&#39;+options.rowId+&#39;" name="yes"&#160; value="&#39;+ regID +&#39;" &#39; + (approval==&#39;Yes&#39; ? &#39;checked="checked"&#39; : &#39;&#39;) + &#39;onclick="myFunctionYes(&#39; + options.rowId + &#39;)" /&#62;Yes&#38;nbsp;&#38;nbsp;&#39;+<br />&#160;&#160; &#160;&#160;&#160; &#160;&#39;&#60;input type="checkbox" id="checkBoxNo_&#39;+options.rowId+&#39;"&#160; name="no" value="&#39;+ regID +&#39;" &#39; + (approval==&#39;No&#39; ? &#39;checked="checked"&#39; : &#39;&#39;) + &#39;onclick="myFunctionNo(&#39; + options.rowId + &#39;)" /&#62;No&#39;;<br />&#160;&#160; &#160;}</p>
</p>
<p>I have a button to set all checkboxes to Yes in the grid.&#160; I am looping through all of the records to set the cell value to Yes.&#160; It only seems to set the first page boxes to Yes but no of the other pages have the value checked.&#160; If I manually navigate to say page 2 and press the button then all of the cells are set to Yes.</p>
</p>
<p>function setAllToYes()<br />{<br />&#160;&#160; &#160;var count = $(&#39;#grid&#39;).getGridParam("records");</p>
<p>&#160;&#160; &#160;for (x=1; x&#60;=count;x++)<br />&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;var rowData = $(&#39;#grid&#39;).getRowData(x).approvalSelect;<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#grid&#39;).updateGridRows({approvalSelect:&#39;Yes&#39;}, x, false);<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#grid&#39;).setCell(x,&#39;approvalSelect&#39;,&#39;Yes&#39;);<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#checkBoxYes_&#39; + x).attr(&#39;checked&#39;,true);<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#checkBoxNo_&#39; + x).attr(&#39;checked&#39;,false);<br />&#160;&#160; &#160;&#160;&#160; &#160;$(&#39;#grid&#39;).saveRow(x,false,&#39;clientArray&#39;);&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;var rowData1 = $(&#39;#grid&#39;).getLocalRow(x).approvalSelect;<br />&#160;&#160; &#160;&#160;&#160; &#160;alert(x + " : " + rowData + " : " + rowData1);<br />&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;}</p></p>
]]></description>
        	        	<pubDate>Fri, 28 Oct 2011 19:44:25 +0300</pubDate>
        </item>
</channel>
</rss>