<?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: XML Node Object in Custom Formatter</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/xml-node-object-in-custom-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/xml-node-object-in-custom-formatter/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>casperd on XML Node Object in Custom Formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/xml-node-object-in-custom-formatter#p21368</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/xml-node-object-in-custom-formatter#p21368</guid>
        	        	<description><![CDATA[<p>Hi Oleg,</p>
</p>
<p>Again, thanks for your help!</p>
</p>
<p>I need to use the loadonce (for cleint side sorting, etc). But, using your suggestions, I have now been able to design a very nice generic way for my custom formatters, which could now be used by any of my jqGrids. Here is an example (we could maybe share thsi with the community):</p>
</p>
<p><em>OverdueDate_formatter = function (cellvalue, options, rowObject,</em><em><strong>iCol,sColName</strong>){<br />&#160;&#160;&#160; var bIsOverdue = false;<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;if (rowObject[sColName] == undefined){<br />&#160;&#160; &#160;&#160;&#160; &#160;if (rowObject.childNodes[iCol].textContent == "True"){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;bIsOverdue = true;<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;}<br />&#160;&#160; &#160;else{<br />&#160;&#160; &#160;&#160;&#160; &#160;if (rowObject[sColName] == "True"){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;bIsOverdue = true;<br />&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;}</em></p>
<p>&#160;&#160; &#160;if (bIsOverdue){<br />&#160;&#160; &#160;&#160;&#160; &#160;return "&#60;a href=&#39;Reports/RPT_Dashboard.asp?ReportProjectID=" + options.rowId + "&#39; target=_new title=&#39;Progress Updates on this project is outdated! Click to open the latest Project Dashboard&#39; class=&#39;dashboardRectangleRed&#39;&#62;" + $.fmatter.util.DateFormat("m/d/Y",cellvalue,"d M Y",$.jgrid.formatter.date) + "&#60;/a&#62;";<br />&#160;&#160; &#160;}<br />&#160;&#160; &#160;else{<br />&#160;&#160; &#160;&#160;&#160; &#160;return "&#60;a href=&#39;Reports/RPT_Dashboard.asp?ReportProjectID=" + options.rowId + "&#39; target=_new title=&#39;Click to open the latest Project Dashboard&#39; class=&#39;dashboardRectangleGreen&#39;&#62;" + $.fmatter.util.DateFormat("m/d/Y",cellvalue,"d M Y",$.jgrid.formatter.date) + "&#60;/a&#62;";<br />&#160;&#160; &#160;}<br />}</p>
</p>
<p>So, from the colmodel, I would have a definition like:</p>
<p><em>{name:&#39;ProjectStatusDate&#39;, width:90, align:&#39;center&#39;, sorttype:&#39;date&#39;,formatter:function(cellvalue,options,rowObject){return OverdueDate_formatter(cellvalue,options,rowObject,<strong>4,"IsOverdue"</strong>);}},</em></p>
</p>
<p>I have added two parameters to my custom formatter function:</p>
<p>&#160;- the first is the column ID to be checked;</p>
<p>&#160;- the second is the column name to be checked.</p>
</p>
<p>Then within the formatter fucntion, I do a test to determine whether the dataset is currently remote or local, and then determine how to format, using the correct calling convention.</p>
</p>
<p>Thanks again for all your help!!</p>
</p>
<p>Cheers,</p>
<p>Cas</p>
]]></description>
        	        	<pubDate>Tue, 21 Dec 2010 06:57:37 +0200</pubDate>
        </item>
        <item>
        	<title>OlegK on XML Node Object in Custom Formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/xml-node-object-in-custom-formatter#p21354</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/xml-node-object-in-custom-formatter#p21354</guid>
        	        	<description><![CDATA[<p>Hello Cas,</p>
<p>It seems to me that you have almost the same problem as described <a href="http://stackoverflow.com/questions/4485970/jqgrid-rowobject-inconsistencies/4486142#4486142" target="_blank">here</a>. I suppose you use <strong>loadonce:true</strong> option. After the changing the <strong>datatype</strong> to <strong>&#39;local&#39;</strong>, the <strong>rowObject</strong> will be <em>no more XML object</em>.&#160;It will be JavaScript object, the element from the internal <strong>data</strong> parameter where the local data are saved.</p>
<p>So I recommend you test inside of your custom formatter function&#160;</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6793' value='Select Code' data-codeid='sfcode6793' /></p>
<div class='sfcode' id='sfcode6793'>if (typeof rowObject.childNodes === &#34;undefined&#34;) {<br />&#160;&#160; &#160;// rowObject is element from the local data<br />&#160;&#160; &#160;// you can access the fields with dotted notation like rowObject.ProjectName<br />} else {<br />&#160;&#160; &#160;// rowObject is initial XML object<br />}</div>
<p>Best regards<br />Oleg&#160;</p>
]]></description>
        	        	<pubDate>Mon, 20 Dec 2010 13:55:18 +0200</pubDate>
        </item>
        <item>
        	<title>casperd on XML Node Object in Custom Formatter</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/xml-node-object-in-custom-formatter#p21353</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/xml-node-object-in-custom-formatter#p21353</guid>
        	        	<description><![CDATA[<p>Hi Oleg,</p>
</p>
<p>I have the following grid definition:</p>
<p><em>$("#tblActiveProjects").jqGrid({<br />&#160; url:&#39;../Data_Templates/DTM_Projects_Select.asp?FilterType=1&#38;TeamMemberType=1&#39;,<br />&#160; colNames: [&#39;&#39;,&#39;Project Name&#39;, &#39;Status&#39;,&#39;Latest Update&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;Issues&#39;,&#39;I-O&#39;,&#39;Risks&#39;,&#39;R-O&#39;,&#39;Changes&#39;,&#39;Defects&#39;],<br />&#160; colModel: [<br />&#160;&#160;&#160; {name:&#39;ProjectRAGIndicator&#39;, width:20, align:&#39;center&#39;, sortable:false, formatter:RAG_formatter},<br />&#160;&#160;&#160; {name:&#39;ProjectName&#39;, width:570, align:&#39;left&#39;, sorttype:&#39;text&#39;, formatter:function(cellvalue,options,rowObject){return ProjectLink_formatter(cellvalue,options,rowObject,6);}, classes:&#39;gridLink&#39;},<br />&#160;&#160;&#160; {name:&#39;ProjectStatus&#39;, width:90, align:&#39;center&#39;, sorttype:&#39;text&#39;},<br />&#160;&#160;&#160; {name:&#39;ProjectStatusDate&#39;, width:90, align:&#39;center&#39;, sorttype:&#39;date&#39;, formatter:OverdueDate_formatter},<br />&#160;&#160;&#160; {name:&#39;IsOverdue&#39;, width:0, align:&#39;center&#39;, hidden:true},<br />&#160;&#160;&#160; {name:&#39;LinkToDashboard&#39;, width:0, align:&#39;center&#39;, hidden:true},<br />&#160;&#160;&#160; {name:&#39;LinkToWorkspace&#39;, width:0, align:&#39;center&#39;, hidden:true},<br />&#160; &#160; {name:&#39;ActiveIssues&#39;, width:50, align:&#39;center&#39;, sortable:false},<br />&#160;&#160;&#160; {name:&#39;ActiveIssuesOverdue&#39;, width:0, align:&#39;center&#39;, hidden:true},<br />&#160;&#160;&#160; {name:&#39;ActiveRisks&#39;, width:50, align:&#39;center&#39;, sortable:false},<br />&#160;&#160;&#160; {name:&#39;ActiveRisksOverdue&#39;, width:0, align:&#39;center&#39;, hidden:true},<br />&#160;&#160;&#160; {name:&#39;ActiveChanges&#39;, width:50, align:&#39;center&#39;, sortable:false},<br />&#160;&#160;&#160; {name:&#39;ActiveDefects&#39;, width:50, align:&#39;center&#39;, sortable:false}<br />&#160; ],<br />&#160;&#160; pager: &#39;#pagerActiveProjects&#39;,<br />&#160;&#160; gridview: false,<br />&#160;&#160; toolbar: [true,"top"]</em></p>
<p><em>&#160;&#160;&#160;</em> ..................</p>
</p>
<p>The following is the custom formatter function:</p>
<p><em>OverdueDate_formatter = function (cellvalue, options, rowObject){<br />&#160; if (rowObject.childNodes[4].textContent == "True"){<br /></em></p>
<p><em>&#160;&#160;&#160; return "&#60;a href=&#39;Reports/RPT_Dashboard.asp?ReportProjectID=" + options.rowId + "&#39; target=_new title=&#39;Progress Updates on this project is outdated! Click to open the latest Project Dashboard&#39;&#62;" + $.fmatter.util.DateFormat("m/d/Y",cellvalue,"d M Y",$.jgrid.formatter.date) + "&#60;/a&#62;";<br />&#160; }<br />&#160; else{<br />&#160;&#160;&#160; return "&#60;a href=&#39;Reports/RPT_Dashboard.asp?ReportProjectID=" + options.rowId + "&#39; target=_new title=&#39;Click to open the latest Project Dashboard&#39;&#62;" + $.fmatter.util.DateFormat("m/d/Y",cellvalue,"d M Y",$.jgrid.formatter.date) + "&#60;/a&#62;";<br />&#160; }<br />}<br /></em></p>
<p>But it seems that the <em><strong>rowObject.childNodes[4].textContent</strong></em> is only available when the grid is intialize. After I click to sort the grid, this value returns "undefined".</p>
</p>
<p>Any ideas?</p>
</p>
<p>Thanks,</p>
<p>Cas</p></p>
]]></description>
        	        	<pubDate>Mon, 20 Dec 2010 12:57:05 +0200</pubDate>
        </item>
</channel>
</rss>