<?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: templates for columns in colModel</title>
	<link>http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel</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/feature-request/templates-for-columns-in-colmodel/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on templates for columns in colModel</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p21154</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p21154</guid>
        	        	<description><![CDATA[<p>Oleg,</p>
<p>Good arguments.</p>
<p>Also code is changed.</p>
</p>
<p>Best regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Sun, 05 Dec 2010 15:08:21 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on templates for columns in colModel</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p21153</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p21153</guid>
        	        	<description><![CDATA[<p>Hello Tony,</p>
<p>thank you for you answer.</p>
<p>I want only explain why I suggested about having both per column template&#160;<strong>cm.template</strong> and the global template <strong>$.jgrid.defaults.cmTemplate</strong>.</p>
<p>Of cause all settings can be done with <strong>cm.template</strong> only, but there are one small problem. The default setting for <strong>cmTemplate</strong>,<strong>&#160;</strong>which I included in my suggestion, are really already set into the grid by default. It&#39;s correct, but the settings are done in different places of jqGrid code and the defaults<strong>&#160;can not be changed</strong>. For example what if somebody just want to have right alignment for all columns or if he want to switch off the sorting or the resizing of the columns, or to switch off the cells tooltips or just change default width of all columns to another value as 150px? One can of cause create some column templates and place the corresponding setting in all the column template definition, but is it not more elegant to be able to change/overwrite&#160;a global jqGrid setting in one line of JavaScript code?</p>
<p>I write all this not to make more pressure on you. No way! You should decide <em>yourself</em> what you want to implement in the next version of the jqGrid. I wanted only be sure that you understand my logic and my suggestion absolutely correct.</p>
<p>Best regards<br />Oleg</p>
]]></description>
        	        	<pubDate>Sun, 05 Dec 2010 14:13:47 +0200</pubDate>
        </item>
        <item>
        	<title>tony on templates for columns in colModel</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p21152</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p21152</guid>
        	        	<description><![CDATA[<p>Oleg,</p>
<p>Thanks again for all the improvements.</p>
<p>Let me comment some things.</p>
<p>The grid base code grow and I do not like this to happen.</p>
<p>If I look into the default setting in cmTemplate it seems like all of these are set into the grid by default, so there is no need to repeat them again.</p>
<p>So I will accept this feature only in the second part. There is no need to define defauts: { cmTemplate...}, but just only to define tempate property in colModel.</p>
</p>
<p>Kind Regards and Thanks again</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Sun, 05 Dec 2010 12:50:45 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on templates for columns in colModel</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p20997</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p20997</guid>
        	        	<description><![CDATA[<p>Hi Tony,</p>
<p>You don&#39;t comment my suggestion about the introducing if templates in the jqGrids. In my opinion it could be a very helpful feature of the jqGrid.</p>
<p>For example some people want to use <strong>right </strong>or<strong> center alignment</strong> in the most columns, other people don&#39;t want to have any <strong>sortable</strong>&#160;columns (see my <a href="http://stackoverflow.com/questions/3989736/jqgrid-make-all-columns-not-sortable/3990383#3990383" target="_blank">answer on the stackoverflow.com</a>). One use typically the same column definition parameters for all grid column having the same type like <strong>date</strong> or <strong>checkboxes</strong>. It is clear that there are a lot of examples where one can make the grid definition more simple and clear read after introducing of the templates.</p>
<p>The usage of templates for the <strong>colModel</strong> seems to me so native for jqGrid, that already one versions later after the introducing of the&#160;templates everybody will think that the templates were in the jqGrid starting from its first version.</p>
<p>What is your opinion about this subject?</p>
<p>What think other jqGrid users about this subject?</p>
<p>Best regards<br />Oleg</p>
]]></description>
        	        	<pubDate>Thu, 25 Nov 2010 14:03:41 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on templates for columns in colModel</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p20807</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/templates-for-columns-in-colmodel#p20807</guid>
        	        	<description><![CDATA[<p>Hello Tony!</p>
<p>I suggest very simple change in the <strong>grid.base.js</strong>. It will allows to reduce the code of jqGrids. I suggest to insert between the lines 11 and 12 &#160;</p>
<p>$.extend($.jgrid,{<br /><span style="font-size: 13.8889px; ">&#160;&#160; &#160;htmlDecode : function(value){&#160;</span></p>
<p><span style="font-size: 13.8889px; ">the following code</span></p>
<p>$.extend($.jgrid,{<br /><strong>&#160;&#160; &#160;defaults : {<br />&#160;&#160; &#160; &#160; &#160;cmTemplate: {<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;align: &#39;left&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;sorttype: &#39;text&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;stype: &#39;text&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;edittype: &#39;text&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;width: 150,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;resizable: true,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;search: true,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;sortable: true,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;title: true,<br />&#160;&#160; &#160;&#160;&#160; &#160; &#160; &#160;viewable: true<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;},<br /></strong>&#160;&#160; &#160;htmlDecode : function(value){&#160;</p>
<p>Now we can replace line 852</p>
<p>var i, dir,ts;</p>
<p>to the following</p>
<p>var i,dir,ts<strong>,colMod=this.p.colModel,cmLength=colMod.length,cm</strong>;<br /><strong>for (i=0;i&#60;cmLength;i++){<br />&#160;&#160; &#160;cm = colMod[i];<br />&#160;&#160; &#160;cm = $.extend(cm, $.jgrid.defaults.cmTemplate, cm.template &#124;&#124; {});<br />&#160;&#160; &#160;cm.index = cm.index &#124;&#124; cm.name;<br />&#160;&#160; &#160;cm[i] = cm;<br />}</strong></p>
<p>Now a lot of <strong>colModel</strong> from jqGrids can be simplified. For example the column model from <a href="http://trirand.com/blog/jqgrid/jqgrid.html" target="_blank">the jqGrid Demo</a> "Neu in Version 3.7&#8243;, "Add/edit/delete on local data" can be simplified to the following</p>
<p><input type='button' class='sfcodeselect' name='sfselectit2662' value='Select Code' data-codeid='sfcode2662' /></p>
<div class='sfcode' id='sfcode2662'>
<p>$.extend($.jgrid.defaults.cmTemplate, { editable:true });<br /><span style=&#34;font-size: 11.8056px;&#34;>var numberTemplate = {width:80,align:&#34;right&#34;,editrules:{number:true},sorttype:&#39;number&#39;,formatter:&#39;number&#39;};<br /><span style=&#34;font-size: 11.8056px;&#34;>jQuery(&#34;#crud&#34;).jqGrid({<br /><span style=&#34;font-size: 11.8056px;&#34;>colModel:[<br /><span style=&#34;font-size: 11.8056px;&#34;>&#160;&#160; &#160;{name:&#39;id&#39;, width:55, editoptions:{readonly:true}, sorttype:&#39;int&#39;},<br /><span style=&#34;font-size: 11.8056px;&#34;>&#160;&#160; &#160;{name:&#39;invdate&#39;, width:90, sorttype:&#39;date&#39;, editrules:{date:true},<br /><span style=&#34;font-size: 11.8056px;&#34;>&#160;&#160; &#160; formatter:&#39;date&#39;, datefmt:&#39;d/m/Y&#39;},<br /><span style=&#34;font-size: 11.8056px;&#34;>&#160;&#160; &#160;{name:&#39;name&#39;,index:&#39;name asc, invdate&#39;, width:100 },<br /><span style=&#34;font-size: 11.8056px;&#34;>&#160;&#160; &#160;{name:&#39;amount&#39;,template:numberTemplate },<br /><span style=&#34;font-size: 11.8056px;&#34;>&#160;&#160; &#160;{name:&#39;tax&#39;,template:numberTemplate },<br /><span style=&#34;font-size: 11.8056px;&#34;>&#160;&#160; &#160;{name:&#39;total&#39;,template:numberTemplate },<br /><span style=&#34;font-size: 11.8056px;&#34;>&#160;&#160; &#160;{name:&#39;note&#39;, width:150, sortable:false }<br /><span style=&#34;font-size: 11.8056px;&#34;>]<br /><span style=&#34;font-size: 11.8056px;&#34;>&#8230;&#160;</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
</div>
<p><span style="font-size: 13.8889px;">The code will be more short and more easy to read.</span></p>
<p>Moreover I included in the suggested code changes the setting of <strong>index</strong> property if it is not yet set. It allows to make the usage of this property more easy (instead of permanent usage of code like ts.p.colModel[i].index &#124;&#124; ts.p.colModel[i].name).</p>
<p>I use for example checkboxs in the jqGrid in one of the projects. The following template would be very helpfull</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3484' value='Select Code' data-codeid='sfcode3484' /></p>
<div class='sfcode' id='sfcode3484'>var checkboxTemplate = { width: 20, formatter: &#39;checkbox&#39;, align: &#39;center&#39;,<br />&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; edittype: &#39;checkbox&#39;,&#160;<span style=&#34;&#34;&#34;font-size:&#34;&#34;>editoptions: { value: &#34;1:0&#8243; },<br />&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; stype: &#39;select&#39;,<br />&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; searchoptions: { value: &#34;:;1:Yes;0:No&#34;,<br />&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;sopt: [&#39;eq&#39;, &#39;ne&#39;] }}</span></div>
</p>
<p><span style="font-size: 13.8889px;">Best regards</span></p>
<p><span style="font-size: 13.8889px;"><span style="font-size: 13.8889px;">Oleg&#160;</span></span></p>
]]></description>
        	        	<pubDate>Sun, 14 Nov 2010 17:21:55 +0200</pubDate>
        </item>
</channel>
</rss>