<?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: Sorting xml and combining columns</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns</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/sorting-xml-and-combining-columns/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>theosoft on Sorting xml and combining columns</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2398</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2398</guid>
        	        	<description><![CDATA[<p>It seems I&#39;ve figured it out on the server side.</p>
<p>Let me show you what I&#39;ve done, in case it can help anyone else.</p>
<p>Sorting seems to be a little funky, but hey, it suits my purposes. Nice grid btw. I&#39;ve used Rico&#39;s grid and Dojo&#39;s Grid, but this is the easiest implementation so far.</p>
<p>PHP code:</p>
<p>foreach($xml-&#62;NewDataSet-&#62;Table as $unit){<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; $data[] = array(&#39;TenantID&#39;=&#62;$unit-&#62;TenantID,<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#39;Name&#39;=&#62;$unit-&#62;sFName." ".$unit-&#62;sLName,<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#39;Address&#39;=&#62;$unit-&#62;sAddr1."&#60;br /&#62;".$unit-&#62;sCity.", ".$unit-&#62;sRegion."&#38;nbsp; ".$unit-&#62;sPostalCode,<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#39;sPhone&#39; =&#62;$unit-&#62;sPhone,<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#39;sEmail&#39; =&#62;$unit-&#62;sEmail);<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; $sort[&#39;direction&#39;] = $_GET[&#39;sord&#39;]==&#39;desc&#39; ? &#39;SORT_DESC&#39; : &#39;SORT_ASC&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; $sort[&#39;field&#39;]&#160;&#160;&#160;&#160;&#160;&#160; = $_GET[&#39;sidx&#39;] ? $_GET[&#39;sidx&#39;] : &#39;TenantID&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; $sort[&#39;sorttype&#39;] = $_GET[&#39;sidx&#39;]==&#39;TenantID&#39;?&#39;SORT_NUMERIC&#39;:&#39;SORT_STRING&#39;;<br />&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; <br />&#160;&#160; <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; /**<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; * @desc Build columns using the values, for sorting in php<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; */<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; $sort_arr = array();<br />&#160;&#160;&#160; &#160;&#160;&#160; foreach($data AS $uniqid =&#62; $row){<br />&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; foreach($row AS $key=&#62;$value){<br />&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $sort_arr[$key][$uniqid] = $value;<br />&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; //print_r($data);<br />&#160;&#160;&#160; &#160;&#160;&#160; if($sort[&#39;direction&#39;]){<br />&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160; array_multisort($sort_arr[$sort[&#39;field&#39;]], constant($sort[&#39;direction&#39;]),constant($sort[&#39;sorttype&#39;]), $data);<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; //print_r($data);<br />&#160;&#160;&#160; &#160;&#160;&#160; echo "&#60;rows&#62;";<br />&#160;&#160;&#160; &#160;&#160;&#160; foreach($data as $key=&#62;$value){<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; echo &#39;&#60;row id="&#39;.$value[&#39;TenantID&#39;].&#39;"&#62;&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; echo &#39;&#60;cell&#62;&#39;.$value[&#39;TenantID&#39;].&#39;&#60;/cell&#62;&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; echo &#39;&#60;cell&#62;&#39;.$value[&#39;Name&#39;].&#39;&#60;/cell&#62;&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; echo &#39;&#60;cell&#62;&#60;![CDATA[&#39;.$value[&#39;Address&#39;].&#39;]]&#62;&#60;/cell&#62;&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; echo &#39;&#60;cell&#62;&#39;.$value[&#39;sPhone&#39;].&#39;&#60;/cell&#62;&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; echo &#39;&#60;cell&#62;&#39;.$value[&#39;sEmail&#39;].&#39;&#60;/cell&#62;&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; echo &#39;&#60;/row&#62;&#39;;<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; &#160;&#160;&#160; echo "&#60;/rows&#62;";</p>
]]></description>
        	        	<pubDate>Wed, 08 Oct 2008 06:38:39 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Sorting xml and combining columns</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2395</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2395</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>1. Yes, server side</p>
<p>2 When you use local xml file then</p>
<p>set</p>
<p>...</p>
<p>datatype: &#39;xml&#39;,</p>
<p>loadonce: true,</p>
<p>...</p>
<p>Set in colModel the appropriate sorttype properies - ie. int,number,string,date and etc. See docs</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Wed, 08 Oct 2008 04:39:44 +0300</pubDate>
        </item>
        <item>
        	<title>theosoft on Sorting xml and combining columns</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2394</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2394</guid>
        	        	<description><![CDATA[<p>I&#39;m not looking to do mutli-column sorting. That&#39;s not a requirement.</p>
<p>I would use dojo grid for that.</p>
<p>1. I would like to combine say the first and last names and the address, city, state, zipcodes.&#160; My question was, should I do that on the backend, or is there a way to do it through the javascript.</p>
<p>2. Sorting does not work like this is written. How can I get it to sort?</p>
<p>Here&#39;s what the javascript looks like:</p>
<p>jQuery("#list1").jqGrid({ <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; url:&#39;method.php?method=TenantList&#39;, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; datatype: "xml", <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; width: 500,<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; height:500,<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; colNames:[&#39;Tenant ID&#39;,&#39;Last Name&#39;, &#39;Address&#39;, &#39;Phone&#39;,&#39;Email&#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;&#160; {name:&#39;TenantID&#39;,index:&#39;TenantID&#39;, width:55, sorttype:&#39;int&#39;}, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;sLName&#39;,index:&#39;sLName&#39;, width:90}, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;sAddr1&#39;,index:&#39;sAddr1&#39;, width:100}, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;sPhone&#39;,index:&#39;sPhone&#39;, width:80}, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; {name:&#39;sEmail&#39;,index:&#39;sEmail&#39;, width:80}], <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; rowNum:10, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; rowList:[10,20,30], <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; imgpath: &#39;js/jqGrid/themes/basic/images&#39;,<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; sortname: &#39;diffgr:id&#39;, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; viewrecords: true, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; sortorder: "desc", <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; xmlReader: { root : "NewDataSet", row: "Table", repeatitems: false, id: "TenantID" }, <br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; caption:"Tenant List"<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; });</p>
</p>
<p>XML (with data removed since it is live data):</p>
<p>&#60;diffgr:diffgram&#62;<br />&#8722;<br />&#60;NewDataSet&#62;<br />&#8722;<br />&#60;Table diffgr:id="Table1" msdata:rowOrder="0"&#62;<br />&#60;SiteID&#62;&#60;/SiteID&#62;<br />&#60;TenantID&#62;&#60;/TenantID&#62;<br />&#60;sLocationCode&#62;&#60;/sLocationCode&#62;<br />&#60;sFName&#62;&#60;/sFName&#62;<br />&#60;sMI/&#62;<br />&#60;sLName&#62;&#60;/sLName&#62;<br />&#60;sCompany/&#62;<br />&#60;sAddr1&#62;&#60;/sAddr1&#62;<br />&#60;sAddr2/&#62;<br />&#60;sCity&#62;&#60;/sCity&#62;<br />&#60;sRegion&#62;&#60;/sRegion&#62;<br />&#60;sPostalCode&#62;&#60;/sPostalCode&#62;<br />&#60;sPhone&#62;&#60;/sPhone&#62;<br />&#60;sEmail/&#62;<br />&#60;sMobile/&#62;<br />&#60;sLicense&#62;002108524&#60;/sLicense&#62;<br />&#60;/Table&#62;</p>
<p>&#60;/NewDataSet&#62;<br />&#60;/diffgr:diffgram&#62;</p>
]]></description>
        	        	<pubDate>Wed, 08 Oct 2008 04:03:56 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Sorting xml and combining columns</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2378</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2378</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>1.Could you please post the code and how xml looks like.</p>
<p>2.Multicolumn sorting is not suported. Instead of this you can put</p>
<p>in index property something like index: &#39;firstname lastname&#39;</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Tue, 07 Oct 2008 09:11:54 +0300</pubDate>
        </item>
        <item>
        	<title>theosoft on Sorting xml and combining columns</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2368</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/sorting-xml-and-combining-columns#p2368</guid>
        	        	<description><![CDATA[<p>I have a xml file I&#39;m pulling into a grid.</p>
<p>I&#39;m using the xmlmap to pull into the grid.</p>
<p>The issue I&#39;m having is attempting to sort the various columns.</p>
<p>It won&#39;t sort at all, even using sorttype.</p>
<p>Should I pass the xml into an xmlstr? This would seem kind of cumbersome.</p>
<p>On another note, I would like to combine columns, such as putting first name and last name together.</p>
<p>Should I manipulate the xml file on the backend to do this in PHP, or is there another way through the js of the jqGrid?</p>
<p>Thanks</p>
]]></description>
        	        	<pubDate>Tue, 07 Oct 2008 06:23:43 +0300</pubDate>
        </item>
</channel>
</rss>