<?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: onSortCol Custom sort</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/onsortcol-custom-sort</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/onsortcol-custom-sort/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Atsistemas on onSortCol Custom sort</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/onsortcol-custom-sort#p28929</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/onsortcol-custom-sort#p28929</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I have a grid where there is a row called &#39;Priority&#39; when the user presses on the header of that row, JQGrid sorts the grid but it orders it placing the value &#39;A&#39; before &#39;A1&#39; that is the logical thing. The problem is that I want to force it to be opposite so I developed this query that it works in my SQL Server:</p>
<p><em>"CASE Prioridad </em></p>
<p><em>WHEN &#39;A1&#39; THEN 1 </em></p>
<p><em>WHEN &#39;A&#39; THEN 2 </em></p>
<p><em>WHEN &#39;B&#39; THEN 3 </em></p>
<p><em>WHEN &#39;C&#39; THEN 4 </em></p>
<p><em>WHEN &#39;E&#39; THEN 5 </em></p>
<p><em>ELSE Prioridad + 6 END, Prioridad"</em></p>
</p>
<p>I applied it in my code (I use JQgrid for PHP) as follows:</p>
</p>
<p><em>$colo = &#60;&#60;&#60;ONSORTCOL<br />&#160;&#160; &#160;function (index, columnIndex, sortOrder) {</em></p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;if(index==&#39;Prioridad&#39;){<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $("#grid").jqGrid(&#39;setGridParam&#39;,{<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortname: "CASE Prioridad WHEN &#39;A1&#39; THEN 1 WHEN &#39;A&#39; THEN 2 WHEN &#39;B&#39; THEN 3 WHEN &#39;C&#39; THEN 4 WHEN &#39;E&#39; THEN 5 ELSE Prioridad + 6 END, Prioridad "+sortOrder});<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // trigger the grid<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $("#grid").trigger(&#39;reloadGrid&#39;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // return stop to prevent other things<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return &#39;stop&#39;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; }<br />ONSORTCOL;<br />$grid-&#62;setGridEvent(&#39;onSortCol&#39;,$colo);</p>
</p>
<p>But JQGrid automatically removes the<em> " &#39; "</em> character, and does the same with the<em> " ( "</em> and "<em>) " </em>characters if I replace the chars for CHAR(65) for example.</p>
</p>
<p>Do you have any ideas?</p>
</p>
<p>Thanks in advance.</p>
]]></description>
        	        	<pubDate>Fri, 31 May 2013 17:50:44 +0300</pubDate>
        </item>
</channel>
</rss>