<?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: Registering a customer formatter</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-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/registering-a-customer-formatter/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>SimonL on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12386</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12386</guid>
        	        	<description><![CDATA[<p>Thanks Tony, I&#39;ve downloaded 3.6.1 and I can now set my custom formatters as defaults, thanks again.</p>
</p>
<p>Also, is it possible to set columns as defaults. I have two columns (the edit and delete button columns described above) that appear on every grid in my application. I&#39;ve quickly tried using</p>
</p>
<p>...</p>
<p>$.extend($.jgrid.defaults, {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames: [<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;Edit&#39;, &#39;Delete&#39;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel: [<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;editLink&#39;, fixed: true, resizable: false, search: false, sortable: false, hidden: false, index: &#39;editLink&#39;, width: 30, align: &#39;center&#39;, formatter: &#39;editButtonFormatter&#39; },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;delButton&#39;, fixed: true, resizable: false, search: false, sortable: false, hidden: false, index: &#39;delButton&#39;, width: 60, align: &#39;center&#39;, formatter: &#39;deleteButtonFormatter&#39; }</p>
<p>]</p>
<p>...</p>
</p>
<p>but without success. Before I spend too much time on it, is it actally possible to do this.</p>
</p>
<p>Regards,</p>
<p>Simon</p>
]]></description>
        	        	<pubDate>Tue, 24 Nov 2009 05:00:12 +0200</pubDate>
        </item>
        <item>
        	<title>SimonL on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12353</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12353</guid>
        	        	<description><![CDATA[<p>Thanks Tony, I will download 3.6.1 tomorrow and give it a try, thanks again for you quick response.</p>
</p>
<p>Regards,</p>
<p>Simon</p>
]]></description>
        	        	<pubDate>Mon, 23 Nov 2009 12:11:46 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12352</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12352</guid>
        	        	<description><![CDATA[<p>Hello Simon,</p>
<p>Thanks for this too. There was another bug regrading this. Also I have fixed this and you can download the 3.6.1 release with the fix.</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 23 Nov 2009 12:08:55 +0200</pubDate>
        </item>
        <item>
        	<title>SimonL on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12325</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12325</guid>
        	        	<description><![CDATA[<p>Thank you Tony and Mark for your replies. A combination of your two solutions does help. the editButtonFormatter function is at least now being called, but there seem to still be soome issues. Originally when I called the editButtonFormatter by just adding the function to my code without going dow the $.fn.fmatter.editButtonFormatter route the cellValue parameter was undefined,</p>
<p>the options parameter held values of the colModel etc and rowObject held the values of the other columns on the row. I&#39;m using a value in the rowObject to pick out a particular column value so rowObject is important to me.</p>
<p>However, when I define the editButtonFormatter via $.fn.fmatter.editButtonFormatter and wrap it in quotes in the colModel. Then when editButtonFormatter is called the cellvalue parameter is undefined, the options parameter does hold the colModel details but the rowObject contains "add" and not the values of the other columns in the row. So there do still appear to be some problems.</p>
</p>
<p>Is there anything else I should try?</p>
</p>
<p>Regards,</p>
<p>Simon</p>
]]></description>
        	        	<pubDate>Mon, 23 Nov 2009 08:04:58 +0200</pubDate>
        </item>
        <item>
        	<title>markw65 on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12293</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12293</guid>
        	        	<description><![CDATA[<blockquote>
<p>Tony wrote:</p>
<p>In other word &#8211; make your function with lowecase words &#8211; i.e editbuttonformatter (and call it with lower cases) and it will work.</p>
</blockquote>
<p>I think that&#39;s half the answer. But the other half is here:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit9225' value='Select Code' data-codeid='sfcode9225' /></p>
<div class='sfcode' id='sfcode9225'>{ name: &#39;editLink&#39;, search: false, sortable: false, hidden: false, index: &#39;editLink&#39;, width: 20, align: &#39;center&#39;, formatter: editButtonFormatter }</div>
</p>
<p>I believe you need to pass in a string:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit4748' value='Select Code' data-codeid='sfcode4748' /></p>
<div class='sfcode' id='sfcode4748'>formatter: "editButtonFormatter"</div>
</p>
<p>(and I dont think the case matters here, just in the definition).</p>
</p>
<p>Mark</p>
]]></description>
        	        	<pubDate>Sat, 21 Nov 2009 12:37:43 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12288</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12288</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Testing your exact example brig to not working code:</p>
<p>The reason is this pice of code (I will correct it in 3.6.1)</p>
<p><input type='button' class='sfcodeselect' name='sfselectit9680' value='Select Code' data-codeid='sfcode9680' /></p>
<div class='sfcode' id='sfcode9680'>
<p>&#160;&#160;&#160; function fireFormatter(formatType,cellval, opts, rwd, act) {<br />&#160;&#160;&#160; &#160;&#160;&#160; <strong>formatType = formatType.toLowerCase();</strong><br />&#160;&#160;&#160; &#160;&#160;&#160; var v=cellval;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if ($.fn.fmatter[formatType]){<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; v = $.fn.fmatter[formatType](cellval, opts, act);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return v;<br />&#160;&#160;&#160; };</p>
</div>
<p>In other word - make your function with lowecase words - i.e editbuttonformatter (and call it with lower cases) and it will work.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Sat, 21 Nov 2009 11:47:07 +0200</pubDate>
        </item>
        <item>
        	<title>SimonL on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12287</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12287</guid>
        	        	<description><![CDATA[<p>Hi Tony,</p>
</p>
<p>I tried you suggestion but unfortunately I still get the error.</p>
</p>
<p>My code ...</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $.fn.fmatter.editButtonFormatter = function(cellval,opts) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return "Edit Link";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; };</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery(gridSelector).jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; url: &#39;/Admin/StockOwner/GetListData/&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; editURL: &#39;/Admin/StockOwner/Edit/&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; deleteURL: &#39;/Admin/StockOwner/Delete/&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;json&#39;,<br />....</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel: [<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;editLink&#39;, search: false, sortable: false, hidden: false, index: &#39;editLink&#39;, width: 20, align: &#39;center&#39;, formatter: editButtonFormatter },</p>
<p>....</p>
<p>Regards,</p>
<p>Simon</p></p>
]]></description>
        	        	<pubDate>Sat, 21 Nov 2009 11:22:30 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12286</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12286</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>IMHO this should work.</p>
<p>Instead can you try this way</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6489' value='Select Code' data-codeid='sfcode6489' /></p>
<div class='sfcode' id='sfcode6489'>
<p>$.fn.fmatter.editButtonFormatter = function(cellval,opts) {</p>
<p>// do something here</p>
<p>}</p>
</div>
<p>Tony</p>
<p>P.S. I will try to reproduce your code.</p>
<p>Regards</p></p>
]]></description>
        	        	<pubDate>Sat, 21 Nov 2009 10:54:59 +0200</pubDate>
        </item>
        <item>
        	<title>SimonL on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12282</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12282</guid>
        	        	<description><![CDATA[<p>Hi Tony,</p>
</p>
<p>Yes thats how I call it in my grid code:</p>
</p>
<p>colModel[</p>
<p>{</p>
<p>...</p>
<p>name: &#39;editLink&#39;, search: false, sortable: false, hidden: false, index: &#39;editLink&#39;, width: 20, align: &#39;center&#39;, formatter: editButtonFormatter },</p>
<p>...</p>
<p>]</p>
<p>But this causes the "editButtonFormatterfuntion is not defined" error.</p>
</p>
<p>When I was creating the function initially I just added a function underneath my grid code like so:</p>
<pre class="code javascript"><span class="sy0"><br /></span>function editButtonFormatter (cellvalue, options, rowObject) {<br />&#160;return "Edit Link";<br />          &#160;//  Note: I&#39;ve edited out the real code here just to make it very simple - but it still doesn&#39;t get registered     <br />           //                var editURL = $(gridSelector).getGridParam(&#39;editURL&#39;);<br />          &#160;//                return "&#60;a href=" + editURL + getPrimaryKey(rowObject) + "&#62;" + "Edit" + "&#60;/&#62;";            }       <br /> });<br /><br /></pre>
<p>and called it from the grid model as described above and everything worked fine.&#160;</p>
<p>I then removed the function and defined it with the</p>
<pre class="code javascript">$.extend($.fn.fmatter, ......<br /><br />as described in the previous post. Even if I add the $.extend($.fn.fmatter, ...... code immediately before my grid definition code, <br />I still get the error.<br /><br />Regards,<br />Simon <br /></pre></p>
]]></description>
        	        	<pubDate>Sat, 21 Nov 2009 09:45:09 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12275</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12275</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>How you call it into the code?</p>
<p>Maybe you will call it this way:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3852' value='Select Code' data-codeid='sfcode3852' /></p>
<div class='sfcode' id='sfcode3852'>
<p>colModel[</p>
<p>{name&#39;some&#39;... formatter:&#39;editButtonFormatter&#39;...},</p>
<p>...</p>
<p>]</p>
<p>...</p>
</div>
]]></description>
        	        	<pubDate>Sat, 21 Nov 2009 08:12:11 +0200</pubDate>
        </item>
        <item>
        	<title>SimonL on Registering a customer formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12223</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/registering-a-customer-formatter#p12223</guid>
        	        	<description><![CDATA[<pre class="code javascript"><span class="sy0">Hi,<br /><br />I wrote a custom formatter and it works perfectly well. I want to use it in all my grids in my application so I decided to <br />use the extends function to register it  (I&#39;m using version 3.5 of jqGrid). But when I run my application firebug tells me that the  <br /></span>editButtonFormatter function is not defined. <br /><br />I have the following code that runs after jqGrid javascript file is loaded. <br /><span class="sy0"><br />&#60;</span>script type<span class="sy0">=</span><span class="st0">"text/javascript"</span><span class="sy0">&#62;</span><br />        $.extend($.fn.fmatter, {<br />        editButtonFormatter: function(cellvalue, options, rowObject) {<br />                return "Edit Link";<br />                //  Note: I&#39;ve edited out the real code here just to make it very simple - but it still doesn&#39;t get registered<br />                //                var editURL = $(gridSelector).getGridParam(&#39;editURL&#39;);<br />                //                return "&#60;a href=" + editURL + getPrimaryKey(rowObject) + "&#62;" + "Edit" + "&#60;/&#62;";<br />            }<br />        });<br />&#60;/script&#62;<br /><br />Can you tell me what I&#39;m doing wrong please.<br /><br />Regards,<br />Simon</pre>
]]></description>
        	        	<pubDate>Fri, 20 Nov 2009 06:17:44 +0200</pubDate>
        </item>
</channel>
</rss>