<?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: checkbox formatting and editing</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing</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/checkbox-formatting-and-editing/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p18058</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p18058</guid>
        	        	<description><![CDATA[</p>
<p>Hello,</p>
<p>If I understand right the problem, here is some code from our support DB</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3112' value='Select Code' data-codeid='sfcode3112' /></p>
<div class='sfcode' id='sfcode3112'>
<p>&#160;&#160; jQuery(&#39;#list1&#39;).jqGrid({<br /> &#160; &#160; &#160; &#160;url:&#39;&#60;?=$base_url.&#39;index.php/</p>
<div class="im">bio/gridServerPart&#39;?&#62;&#39;,<br /> //function in Bio controller to render grid<br /> &#160; &#160; &#160; &#160;mtype : &#39;post&#39;, &#160; &#160; &#160; &#160; &#160; &#160; //Ajax request type<br /> &#160; &#160; &#160; &#160;datatype: "xml", &#160; &#160; &#160; &#160; &#160; &#160;//XML, JSON or Arrray<br /> &#160; &#160; &#160; &#160;colNames:[&#39;name&#39;,&#39;sent_flag&#39;], &#160; &#160; &#160; //Grid column headings<br /> &#160; &#160; &#160; &#160;colModel:[<br /> &#160; &#160; &#160; &#160; &#160; &#160;{name:&#39;name&#39;, width:100, align:&#39;left&#39;, search: false},<br /> &#160; &#160; &#160; &#160; &#160; &#160;{name:&#39;sent_flag&#39;, width:100, align:&#39;left&#39;, sortable:false,</div>
<div class="im">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; formatter: &#39;checkbox&#39;, formatoptions: {disabled : false}}<br /> &#160; &#160; &#160; &#160; &#160; &#160;}<br /> &#160; &#160; &#160; &#160;],</div>
<p>// beforeSelect row raises before selecting a row.<br /> // to this event we pas the id and the event element<br /> &#160; &#160; &#160; &#160;beforeSelectRow : function(rowid, elem) {<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;// lets get the target<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;var e = elem.target;<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;// if this is a input element which is check box<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;if(e.tagName == "INPUT" &#38;&#38; e.type == &#39;checkbox&#39;) {<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;// lets get the value.<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; // NOTE &#160;- the state of checkbox is obtained<br /> with jQuery attr and not val()- this is a common error<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;var cbvalue = $(e).attr("checked");</p>
<p><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(cbvalue) cbvalue = &#39;O&#39;;</strong></p>
<p><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else cbvalue = &#39;N&#39;<br /></strong></p>
<p>&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;//lets post the value to the controler<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;$.ajax({<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;url:&#39;&#60;?=$base_url.&#39;index.php/bio/gridPost&#39;?&#62;&#39;,</p>
<div id=":a0" class="ii gt">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;method:&#39;POST&#39;,<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;// here you can post any other additional data<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;data : {id:rowid, sent_flag: cbvalue},<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;success :function(response, status) {<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;// check here the response<br /> &#160; &#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; &#160;error : function(response) {<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;// alert &#160;if errorr<br /> &#160; &#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;});</p>
<p> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;}<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;// the event in this case should return in all cases&#160; true, if it return false, the row will not be selected<br /> &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;return true;<br /> &#160; &#160; &#160; &#160;},</p>
<div class="im">&#160; &#160; &#160;&#160; rowNum:1,<br /> &#160; &#160; &#160; &#160;width: 650,<br /> &#160; &#160; &#160; &#160;height: 240,<br /> &#160; &#160; &#160; &#160;rowList:[10,20],<br /> &#160; &#160; &#160; &#160;pager: &#39;#pager1&#39;,<br /> &#160; &#160; &#160; &#160;sortname: &#39;id&#39;,<br /> &#160; &#160; &#160; &#160;viewrecords: true,<br /> &#160; &#160; &#160; &#160;caption:"jQGrid and Codeigniter"<br /> &#160; &#160;}); </div>
</div>
<div class="im"></div>
<div class="im">Regards</div>
<div class="im">Tony</div>
</div>
]]></description>
        	        	<pubDate>Sun, 20 Jun 2010 11:00:37 +0300</pubDate>
        </item>
        <item>
        	<title>Asshiah on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17908</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17908</guid>
        	        	<description><![CDATA[<p>In fact, this code fixes the problem in IE 8 but not in IE7 because in IE7 the behaviour when clicking a box is not the same.</p>
</p>
<p>I also had to use this code in order to work in any current navigator plus IE7:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit1610' value='Select Code' data-codeid='sfcode1610' /></p>
<div class='sfcode' id='sfcode1610'>function ajaxSaveUsers(rowid, colid) {<br />&#160;&#160;&#160; val = $(&#39;#grid_users&#39;).getCell(rowid, colid);</p>
<p>&#160;&#160;&#160; if(typeof(IE7) == &#34;undefined&#34;)<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; newValue = &#34;N&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (val == &#34;N&#34;) newValue = &#34;O&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $(&#34;#grid_users&#34;).setCell(rowid, colid, newValue);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; val = $(&#39;#grid_users&#39;).getCell(rowid, colid);<br />&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; $.ajax({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; type:&#34;POST&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; url:&#34;./handlers/UsersJqGridEdit.ashx&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; data: {&#34;oper&#34;: &#34;edit&#34;, &#34;usr_actif&#34;: val, &#34;id&#34;: rowid},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; success: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; error: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert(&#39;An error has occured.&#39;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; })<br />}</p>
</div>
<p>So please use the previous code for the unformatter (for IE8) plus this code for the save function (for IE7).</p>
</p>
<p>This save function code assumes you specified thid in the header of your current page:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit8893' value='Select Code' data-codeid='sfcode8893' /></p>
<div class='sfcode' id='sfcode8893'>&#60;!&#8211;[if IE 7]&#62;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;script type=&#34;text/javascript&#34;&#62;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var IE7 = true;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/script&#62;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;![endif]&#8211;&#62;</div></p>
]]></description>
        	        	<pubDate>Mon, 14 Jun 2010 15:23:54 +0300</pubDate>
        </item>
        <item>
        	<title>Asshiah on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17881</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17881</guid>
        	        	<description><![CDATA[<p>Ok.</p>
</p>
<p>I found the solution.</p>
</p>
<p>It seems IE doesn&#39;t write checked in the html code of the checkbox input but write CHECKED in CAPS.</p>
</p>
<p>So I had to use this code for the unformatter in order for it to work on any navigator:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5730' value='Select Code' data-codeid='sfcode5730' /></p>
<div class='sfcode' id='sfcode5730'>jQuery.extend($.fn.fmatter.checkboxcustom , {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; unformat : function(cellvalue, options, cellobject) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var checked = ($(cellobject).html().indexOf(&#34;checked&#34;,0) != -1 &#124;&#124; $(cellobject).html().indexOf(&#34;CHECKED&#34;,0) != -1) ? &#34;O&#34; : &#34;N&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return checked;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />});</div>
]]></description>
        	        	<pubDate>Fri, 11 Jun 2010 18:49:45 +0300</pubDate>
        </item>
        <item>
        	<title>Asshiah on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17880</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17880</guid>
        	        	<description><![CDATA[<p>In fact, when we are clicking on a box, the unformat method is called.</p>
</p>
<p>On every navigator except IE, if a bos is checked and we click on it, the unformat method will return return "O" when on IE it will return "N".</p>
</p>
<p>in IE, $(cellobject).html().indexOf("checked",0) will return -1 when its not on other navigator</p>
]]></description>
        	        	<pubDate>Fri, 11 Jun 2010 18:35:44 +0300</pubDate>
        </item>
        <item>
        	<title>Asshiah on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17875</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17875</guid>
        	        	<description><![CDATA[<p>I have made some more test.</p>
</p>
<p>It appears than in any navigator except from IE, if a box is checked and I use the getcell method, I will obtain the "O" character.</p>
</p>
<p>In IE, I will get the "N" character and using the setcell method to set it to "O" does not seem to work.</p>
]]></description>
        	        	<pubDate>Fri, 11 Jun 2010 17:39:04 +0300</pubDate>
        </item>
        <item>
        	<title>Asshiah on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17870</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17870</guid>
        	        	<description><![CDATA[<p>I have no idea as how to solve this problem on IE. Everything works just fine in other browsers (Opera, Safari, Google Chrome, firefox).</p>
<p>And I have to make this work on IE 7 and 8 as per order from my client...</p>
]]></description>
        	        	<pubDate>Fri, 11 Jun 2010 16:03:47 +0300</pubDate>
        </item>
        <item>
        	<title>Asshiah on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17828</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17828</guid>
        	        	<description><![CDATA[<p>Thank you a lot bkeszler!</p>
<p>I have made some progress thanks to you.</p>
</p>
<p>I have stopped trying to enable the checkboxes in the form editing.</p>
<p>I have set the field as non editable and now I just try to make it editable by clicking on the checkbox directly in the grid and sending an AJAX call.</p>
</p>
<p>Apparently, everything works just fine.</p>
</p>
<p>The only problem is specific to IE (I have tested this on IE8).</p>
<p>While everything is OK with any other navigator, IE8 have some problem with the checkboxes.</p>
<p>If a checkbox is unchecked, I can click on it in the grid in order to check it.</p>
<p>But IE will signal this box as unchecked when proceeding the AJAX call.</p>
<p>If a checkbox is already checked, in IE8, I can&#39;t uncheck it, but IE still signals the box as unchecked when proceeding the AJAX call.</p>
</p>
<p>I don&#39;t have this behaviour in any other navigator.</p>
</p>
<p>Here is the code I use:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5852' value='Select Code' data-codeid='sfcode5852' /></p>
<div class='sfcode' id='sfcode5852'>
<p>$(document).ready(function() {</p>
<p>function ajaxSaveUsers(rowid, colid) {<br />&#160;&#160;&#160; val = $(&#39;#grid_users&#39;).getCell(rowid, colid);</p>
<p>&#160;&#160;&#160; newValue = &#34;N&#34;;<br />&#160;&#160;&#160; if (val == &#34;N&#34;) newValue = &#34;O&#34;;<br />&#160;&#160;&#160; $(&#34;#grid_users&#34;).setCell(rowid, colid, newValue);</p>
<p>&#160;&#160;&#160; val = $(&#39;#grid_users&#39;).getCell(rowid, colid);</p>
<p>&#160;&#160;&#160; $.ajax({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; type:&#34;POST&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; url:&#34;/handlers/UsersJqGridEdit.ashx&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; data: {&#34;oper&#34;: &#34;edit&#34;, &#34;activ&#34;: val, &#34;id&#34;: rowid},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; success: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; error: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alert(&#39;An error has occurred.&#39;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; })<br />}</p>
</p>
<p>&#160;&#160; jQuery.extend($.fn.fmatter , {<br />&#160;&#160;&#160; checkboxcustomUsers : function(cellvalue, options, rowobject) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var checked = cellvalue != &#39;N&#39; ? &#34;checked=&#39;checked&#39; &#34; : &#34;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rtn = &#34;&#60;input type=&#39;checkbox&#39; onclick=&#34;ajaxSaveUsers(&#39;&#34; + options.rowId + &#34;&#39;,&#39;&#34; + options.colModel.name + &#34;&#39;);&#34; &#34; + checked&#160; + &#34; value=&#39;&#34;+ cellvalue+ &#34;&#39; /&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return rtn;<br />&#160;&#160;&#160; }<br />});</p>
<p>jQuery.extend($.fn.fmatter.checkboxcustomUsers , {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; unformat : function(cellvalue, options, cellobject) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var checked = $(cellobject).html().indexOf(&#34;checked&#34;,0) != -1 ? &#34;O&#34; : &#34;N&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return checked;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />});<br />&#160;&#160; &#160;<br />&#160;&#160;  &#160;jQuery(&#34;#grid_users&#34;).jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;json&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#39;POST&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; url: &#34;./handlers/UsersJqGridLoad.ashx&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; editurl: &#34;/handlers/UsersJqGridEdit.ashx&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;  colNames:[&#39;Name&#39;, &#39;Firstname&#39;, &#39;Login&#39;, &#39;Password&#39;, &#39;Activ&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;  colModel :[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;name&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; index:&#39;name&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;  editable:true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;firstname&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;  index:&#39;firstname&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editable:true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;  {name:&#39;login&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; index:&#39;login&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;  editable:true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;password&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;  index:&#39;password&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editable:true,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;  edittype:&#39;password&#39;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;activ&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;  index:&#39;activ&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editable:false,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;  align:&#39;center&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; formatter:&#39;checkboxcustomUsers&#39;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;  ],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; autowidth: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; height: &#34;400&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;  gridview: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortable: false,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortname: &#39;name&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;  sortorder: &#39;asc&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; hidegrid: false,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; caption: &#34;User  Information&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: &#34;#pager_users&#34;<br />&#160;&#160; &#160;});</p>
<p>&#160;&#160;  &#160;jQuery(&#34;#grid_users&#34;).jqGrid(&#39;navGrid&#39;,&#39;#pager_users&#39;,{edit:true,add:false,del:false,search:false,refresh:false});<br />});</p>
</div>
]]></description>
        	        	<pubDate>Wed, 09 Jun 2010 14:30:49 +0300</pubDate>
        </item>
        <item>
        	<title>bkeszler on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17372</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17372</guid>
        	        	<description><![CDATA[<p>I just went through this myself.&#160;&#160;You&#39;re on the right track with the custom formatter.&#160; Your checkboxsave() function needs to parse the input tag to determine the current value and then use the setCell function to change that value.</p>
</p>
<p>Here&#39;s some working code for you to look at.</p>
</p>
<p>&#60;html&#62;<br />&#60;head&#62;<br />&#160; &#60;title&#62;User Security&#60;/title&#62;<br />&#160; &#60;link rel="stylesheet" type="text/css" href="jquery/jquery-ui-1.7.2.custom.css"&#62;<br />&#160; &#60;link rel="stylesheet" type="text/css" href="jquery/ui.jqgrid.css"&#62;<br />&#160; &#60;script src="jquery/jquery-1.4.2.min.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#160; &#60;script src="jquery/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#160; &#60;script src="jquery/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;/head&#62;</p>
<p>&#60;body&#62;</p>
<p>&#60;table id="myGrid"&#62;&#60;/table&#62;</p>
<p>&#60;script&#62;<br />jQuery("#myGrid").jqGrid({<br />&#160; datatype: "local",<br />&#160; height: 250,<br />&#160; colNames:[&#39;User ID&#39;, &#39;Username&#39;, &#39;CB1&#39;, &#39;CB2&#39;, &#39;CB3&#39;],<br />&#160; colModel:[<br />&#160;&#160;&#160; {name:&#39;UserID&#39;, index:&#39;UserID&#39;, width:90, sorttype:"int", editable:false},<br />&#160;&#160;&#160; {name:&#39;Username&#39;,index:&#39;Username&#39;, width:150, editable:false},<br />&#160;&#160;&#160; {name:&#39;CB1&#39;,&#160; index:&#39;CB1&#39;, width:40, sortable:false, align:"center", formatter:checkboxFormatter, formatoptions:{disabled:false}},<br />&#160;&#160;&#160; {name:&#39;CB2&#39;,&#160; index:&#39;CB2&#39;, width:40, sortable:false, align:"center", formatter:checkboxFormatter, formatoptions:{disabled:false}},<br />&#160;&#160;&#160; {name:&#39;CB3&#39;,&#160; index:&#39;CB3&#39;, width:40, sortable:false, align:"center", formatter:checkboxFormatter, formatoptions:{disabled:false}}<br />&#160; ],<br />&#160; caption: "Checkbox Grid"<br />});</p>
<p>var mydata2 = [<br />&#160; {UserID:"amotley", Username:"Al Motley", CB1:"0", CB2:"1", CB3:"0"},<br />&#160; {UserID:"bkeszler", Username:"Brian Keszler", CB1:"1", CB2:"0", CB3:"1"},<br />];</p>
<p>for(var i=0;i &#60; mydata2.length;i++) <br />&#160; jQuery("#myGrid").jqGrid(&#39;addRowData&#39;,mydata2[i].id,mydata2[i]);</p>
<p>//checkboxFormatter to wire onclick event of checkbox <br />function checkboxFormatter(cellval, opts, rowObj) {<br />&#160; cellval = cellval + "";<br />&#160; cellval = cellval.toLowerCase();<br />&#160; var bchk = cellval.search(/(false&#124;0&#124;no&#124;off&#124;n)/i) &#60; 0 ? " checked="checked"" : "";<br />&#160; rtn = "&#60;input type=&#39;checkbox&#39; onclick="ajaxSave(&#39;" + opts.rowId + "&#39;,&#39;" + opts.colModel.name + "&#39;);" " + bchk + " value=&#39;" + cellval + "&#39; offval=&#39;no&#39; /&#62;";<br />&#160; return rtn;<br />}</p>
<p>function getCellValue(content) {<br />&#160; var k1, val = 0;<br />&#160; k1 = content.indexOf(&#39; value=&#39;) + 7;<br />&#160; val = content.substr(k1,3);<br />&#160; val = val.replace(/[^0-1]/g, &#39;&#39;);<br />&#160; return val;<br />}</p>
<p>function ajaxSave(rowid, colid) {<br />&#160; var cbtag = $(&#39;#myGrid&#39;).getCell(rowid, colid);<br />&#160; var val = getCellValue(cbtag);</p>
<p>&#160; newValue = 0;<br />&#160; if (val == 0) newValue = 1;<br />&#160; $("#myGrid").setCell(rowid, colid, newValue);<br />&#160; <br />&#160; cbtag = $(&#39;#myGrid&#39;).getCell(rowid, colid);<br />&#160; val = getCellValue(cbtag);<br />&#160; <br />&#160; $.ajax({<br />&#160;&#160;&#160; type:"GET",<br />&#160;&#160;&#160; <a href="/blog/&#34;gridSave.cfm" target="_blank">url:"gridSave.cfm</a>",<br />&#160;&#160;&#160; cache: false,<br />&#160;&#160;&#160; data: "rowid=" + rowid + "&#38;colid=" + colid + "&#38;cbval=" + val,<br />&#160;&#160;&#160; success: function() {<br />&#160;&#160;&#160;&#160;&#160; //alert(&#39;Success&#39;);<br />&#160;&#160;&#160; },<br />&#160;&#160;&#160; error: function() {<br />&#160;&#160;&#160;&#160;&#160; alert(&#39;An error occurred.&#39;);<br />&#160;&#160;&#160; }<br />&#160; })<br />}</p>
<p>&#60;/script&#62;</p>
<p>&#60;/body&#62;<br />&#60;/html&#62;</p></p>
]]></description>
        	        	<pubDate>Thu, 20 May 2010 23:31:57 +0300</pubDate>
        </item>
        <item>
        	<title>tony on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17332</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17332</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>My first look tell me that you will need to write your custom checkbox element for the form edit and not use the build in one.</p>
<p>It is the same - if your checkbox is not "standart" you will need to do it for the grid display and for the form editing with appropriate custom functions.</p>
</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Thu, 20 May 2010 15:53:57 +0300</pubDate>
        </item>
        <item>
        	<title>Asshiah on checkbox formatting and editing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17327</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/checkbox-formatting-and-editing#p17327</guid>
        	        	<description><![CDATA[<p>Hello,</p>
</p>
<p>I have a problem regarding the use of checkbox in a jqGrid.</p>
</p>
<p>In fact, I have a column in my grid that can only contain the letters &#39;O&#39; or &#39;N&#39;. This is what I get from the server when loading the grid.</p>
<p>The letter &#39;O&#39; means yes and the letter &#39;N&#39; means no.</p>
</p>
<p>I want this column to display checkboxes in the grid instead of these letters.</p>
<p>The checkboxes should be checked if the letter received from the server is &#39;O&#39; and the other way round.</p>
<p>I also want these boxes to be clickable in order for the user to be able to click the boxes directly in the grid.</p>
</p>
<p>I also want the cell where a checkbox was clicked to be saved to the server instantly.</p>
</p>
<p>Also, as I have many columns in my grid, I&#39;d like to be able to use form editing of a row where the input for this column is also a checkbox.</p>
</p>
<p>I figured out that in order to display a checkbox in the grid I should use a custom formatter as the column contains non standard input for checkboxes.</p>
<p>A custom formatter also helps define a click event for saving the data to the server.</p>
</p>
<p>But I can&#39;t figure out how to save the data.</p>
</p>
<p>I also have another problem:</p>
<p>When I click on a box in the grid, if the box&#39;s state is changed, this is not the case for the corresponding box in the associated edit form.</p>
</p>
<p>How can I fix that?</p>
</p>
<p>Here is the code I use:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit2400' value='Select Code' data-codeid='sfcode2400' /></p>
<div class='sfcode' id='sfcode2400'>$(document).ready(function() {<br />&#160;&#160; &#160;function checkboxsave()<br />&#160;&#160; &#160;{<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // I still have to find out how to save the content using an AJAX call<br />&#160;&#160; &#160;}</p>
<p>&#160;&#160; &#160;jQuery.extend($.fn.fmatter , {<br />&#160;&#160; &#160;&#160;&#160; &#160;checkboxcustom : function(cellvalue, options, rowobject) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var checked = cellvalue != &#39;N&#39; ? &#34; checked=&#39;checked&#39; &#34; : &#34;&#34;;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;return &#34;&#60;input type=\&#34;checkbox\&#34; &#34; + checked&#160; + &#34; value=\&#34;&#34;+ cellvalue+ &#34;\&#34; offval=\&#34;N\&#34;&#160; onclick=\&#34;checkboxsave()\&#34; /&#62;&#34;;<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;});</p>
<p>&#160;&#160; &#160;jQuery.extend($.fn.fmatter.checkboxcustom , {<br />&#160;&#160; &#160;&#160;&#160; &#160;unformat : function(cellvalue, options, cellobject) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var checked = $(cellobject).html().indexOf(&#34;checked&#34;,0) != -1 ? &#34;O&#34; : &#34;N&#34;;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;return checked;<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;});<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;jQuery(&#34;#grid_users&#34;).jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;local&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;Name&#39;, &#39;Firstname&#39;, &#39;Login&#39;, &#39;Password&#39;, &#39;Activ&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel :[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;name&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; index:&#39;name&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editable:true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;firstname&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; index:&#39;firstname&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editable:true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;login&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; index:&#39;login&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editable:true<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;password&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; index:&#39;password&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editable:true,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160; edittype:&#39;password&#39;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; },<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;activ&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; index:&#39;activ&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editable:true,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160; align:&#39;center&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; formatter:&#39;checkboxcustom&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; edittype:&#39;checkbox&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editoptions:{value:&#34;O:N&#34;},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; ],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; autowidth: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; height: &#34;400&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; gridview: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortable: false,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortname: &#39;name&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortorder: &#39;asc&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; hidegrid: false,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; caption: &#34;User Information&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: &#34;#pager_users&#34;<br />&#160;&#160; &#160;});<br />&#160;&#160; &#160;jQuery(&#34;#grid_users&#34;).jqGrid(&#39;navGrid&#39;,&#39;#pager_users&#39;,{edit:true,add:false,del:false,search:false,refresh:false});</p>
<p>&#160;&#160; &#160;var lstuser = [<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160; {name:&#34;Gram&#34;,firstname:&#34;Paul&#34;,login:&#34;pgram&#34;,password:&#34;pgram&#34;,activ:&#34;O&#34;},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160; {name:&#34;Gram&#34;,firstname:&#34;Eric&#34;,login:&#34;egram&#34;,password:&#34;egram&#34;,activ:&#34;O&#34;},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160; {name:&#34;Gram&#34;,firstname:&#34;Jack&#34;,login:&#34;jgram&#34;,password:&#34;jgram&#34;,activ:&#34;O&#34;},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160; {name:&#34;Gram&#34;,firstname:&#34;Sami&#34;,login:&#34;sgram&#34;,password:&#34;sgram&#34;,activ:&#34;N&#34;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;];<br />&#160;&#160; &#160;for(var i=0;i&#60;=lstuser.length;i++)<br />&#160;&#160; &#160;&#160;&#160; &#160;jQuery(&#34;#grid_users&#34;).jqGrid(&#39;addRowData&#39;,i+1,lstuser[i]);<br />});</p>
</div>
<p>The checkboxes are displayed correctly when loading the grid. I can click on the boxes in the grid to change their state.</p>
<p>I can edit a row with the input for this column displayed as a checkbox.</p>
<p>But if I change the status of a box from the grid, then click on the row and try to edit it, the two checkboxes from the grid and the edit form don&#39;t match.</p>
<p>And I need to find out how to save the cell when the box is clicked.</p></p>
]]></description>
        	        	<pubDate>Thu, 20 May 2010 14:52:30 +0300</pubDate>
        </item>
</channel>
</rss>