<?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: problems with custom checkbox formatter</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/problems-with-custom-checkbox-formatter</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/problems-with-custom-checkbox-formatter/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>jari.haikonen on problems with custom checkbox formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/problems-with-custom-checkbox-formatter#p27263</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/problems-with-custom-checkbox-formatter#p27263</guid>
        	        	<description><![CDATA[<p>Got it all working (with my version of the checkbox) with this</p>
</p>
<p>&#60;script&#62;</p>
<p>function mychkclick(rowid, colid) {</p>
<p>val = $("#list4").getCell(rowid, colid);</p>
<p>newValue = "1";</p>
<p>if (val == "1") newValue = "2";</p>
<p>$("#list4").setCell(rowid, colid, newValue);</p>
<p>val = $("#list4").getCell(rowid, colid);</p>
<p>}</p>
</p>
<p>jQuery.extend($.fn.fmatter , {</p>
<p>mycheckbox : function(cellvalue, options, rowobject) {</p>
<p>var checked = cellvalue == &#39;2&#39; ? "checked=&#39;checked&#39; " : "";</p>
<p>var disabled = cellvalue == &#39;0&#39; ? "disabled=&#39;disabled&#39; " : "";</p>
<p>rtn = "&#60;input type=&#39;checkbox&#39; onclick="mychkclick(&#39;" + options.rowId + "&#39;,&#39;" + options.colModel.name + "&#39;);" " + checked  + disabled  + "value=&#39;"+ cellvalue+ "&#39; /&#62;";</p>
<p>return rtn;</p>
<p>}</p>
<p>});</p>
<p>jQuery.extend($.fn.fmatter.mycheckbox , {</p>
<p>unformat : function(cellvalue, options, cellobject) {</p>
<p>var checked = $(cellobject).html().indexOf("checked",0) != -1 ? "2" : "1";</p>
<p>return checked;</p>
<p>}</p>
<p>});</p>
</p>
<p>var mydata = [</p>
<p>{id:"1",name:"test",checkbox:1},</p>
<p>{id:"2",name:"test2",checkbox:0},</p>
</p>
<p>];</p>
</p>
<p>jQuery("#list4").jqGrid({</p>
<p>datatype: "local",</p>
<p>data: mydata,</p>
<p>height: 250,</p>
<p>colNames:[&#39;id&#39;,&#39;name&#39;,&#39;checkbox&#39;],</p>
<p>colModel:[</p>
<p>{name:&#39;id&#39;,index:&#39;id&#39;, width:60, sorttype:"int"},</p>
<p>{name:&#39;name&#39;,index:&#39;name&#39;, width:100},</p>
<p>{name:&#39;checkbox&#39;,index:&#39;checkbox&#39;, width:80, align:"right",sorttype:"float",editable:true,edittype:&#39;select&#39;,formatter:&#39;mycheckbox&#39;,formatoptions:{disabled:false}, },</p>
<p>],</p>
<p>multiselect: true,</p>
<p>caption: "Demo"</p>
<p>});</p>
<p>&#60;/script&#62;</p>
]]></description>
        	        	<pubDate>Wed, 05 Sep 2012 09:27:24 +0300</pubDate>
        </item>
        <item>
        	<title>jari.haikonen on problems with custom checkbox formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/problems-with-custom-checkbox-formatter#p27262</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/problems-with-custom-checkbox-formatter#p27262</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>I tried to make my own checkbox formatter (because I need value 0 checkboxes to be disabled and value &#62;0 to be enabled etc) and countered a problem with getCell &#38; multiselect.. oh well actually the problem is with getCell if I got it right. Anyway, I made a simple demo where you can see that if any of the checkboxes on the grid is selected, the "get row 1 checkbox value" gets &#39;yes&#39;, and with any I mean the select row checkboxes too. What am I doing wrong? (ps for the demo I copied the original checkbox formatter. and btw by using formatter:&#39;checkbox&#39; the thing works just right...but I need a custom one)</p>
</p>
<p>here is my full demo code</p>
<p><a href="http://savdoc.sav.fi/democode.txt" target="_blank">http://savdoc.sav.fi/democode.txt</a></p>
]]></description>
        	        	<pubDate>Wed, 05 Sep 2012 08:34:20 +0300</pubDate>
        </item>
</channel>
</rss>