<?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: Custom sorttype</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/custom-sorttype</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/custom-sorttype/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>cjm19682 on Custom sorttype</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/custom-sorttype#p18802</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/custom-sorttype#p18802</guid>
        	        	<description><![CDATA[<div>I am using jqGrid 3.7.2 with local data. For some columns the default sorttypes are not sufficient. I need to provide a custom sorttype, which I understand is possible. I don&#39;t know how to get it to work though. The code below is my best attempt at getting it to work using a technique suggested by Tony in a separate post from OlegK - I can&#39;t make it call the custom sorting function though. The idea is to sort the &#39;Posn&#39; field in the order &#39;GK&#39;-&#62;&#39;DEF&#39;-&#62;&#39;MID&#39;-&#62;&#39;STR&#39;. &#160;Here is the code I&#39;d like to get working. Anyone go any ideas?</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div>&#60;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&#62;</div>
<div>&#60;html&#62;</div>
<div><span style="white-space: pre;"> </span>&#60;head&#62;</div>
<div><span style="white-space: pre;"> </span>&#60;title&#62;Table Testbed&#60;/title&#62;</div>
<div><span style="white-space: pre;"> </span>&#60;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&#62;</div>
<div><span style="white-space: pre;"> </span></div>
<div><span style="white-space: pre;"> </span>&#60;link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/south-street/jquery-ui.css"&#62;</div>
<div><span style="white-space: pre;"> </span>&#60;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&#62;&#60;/script&#62;</div>
<div><span style="white-space: pre;"> </span>&#60;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"&#62;&#60;/script&#62;</div>
<div><span style="white-space: pre;"> </span></div>
<div><span style="white-space: pre;"> </span>&#60;link rel="stylesheet" type="text/css" href="/thirdParty/jqGrid/ui.jqgrid.css" &#62;</div>
<div><span style="white-space: pre;"> </span>&#60;script type="text/javascript" src="/thirdParty/jqGrid/grid.locale-en.js"&#62;&#60;/script&#62;</div>
<div><span style="white-space: pre;"> </span>&#60;script type="text/javascript" src="/thirdParty/jqGrid/jquery.jqGrid.min.js"&#62;&#60;/script&#62;</div>
<div></div>
<div><span style="white-space: pre;"> </span>&#60;script type="text/javascript"&#62;</div>
<div><span style="white-space: pre;"> </span>$().ready(function()</div>
<div><span style="white-space: pre;"> </span>{</div>
<div><span style="white-space: pre;"> </span>tableToGrid("#playerTable",</div>
<div><span style="white-space: pre;"> </span>{</div>
<div><span style="white-space: pre;"> </span>datatype:<span style="white-space: pre;"> </span>"local",</div>
<div><span style="white-space: pre;"> </span>sortable:<span style="white-space: pre;"> </span>true,</div>
<div><span style="white-space: pre;"> </span>hidegrid:<span style="white-space: pre;"> </span>false,</div>
<div><span style="white-space: pre;"> </span>multiselect: <span style="white-space: pre;"> </span>false,</div>
<div><span style="white-space: pre;"> </span>altRows:<span style="white-space: pre;"> </span>true,</div>
<div><span style="white-space: pre;"> </span>height: <span style="white-space: pre;"> </span>"100%",&#160;</div>
<div><span style="white-space: pre;"> </span>width:<span style="white-space: pre;"> </span>"155px",</div>
<div><span style="white-space: pre;"> </span>shrinkToFit:<span style="white-space: pre;"> </span>true,</div>
<div><span style="white-space: pre;"> </span>rowNum: 100,</div>
<div><span style="white-space: pre;"> </span>colNames:<span style="white-space: pre;"> </span>[&#39;Posn&#39;,&#39;Name&#39;],</div>
<div><span style="white-space: pre;"> </span>colModel:<span style="white-space: pre;"> </span>[</div>
<div><span style="white-space: pre;"> </span>{name:&#39;Posn&#39;, index:&#39;Posn&#39;, width:100, sorttype:</div>
<div><span style="white-space: pre;"> </span>function(cell)</div>
<div><span style="white-space: pre;"> </span>{</div>
<div><span style="white-space: pre;"> </span>if (cell==&#39;GK&#39;) return &#39;0&#39;;</div>
<div><span style="white-space: pre;"> </span>if (cell==&#39;DEF&#39;) return &#39;1&#39;;</div>
<div><span style="white-space: pre;"> </span>if (cell==&#39;MID&#39;) return &#39;2&#39;;</div>
<div><span style="white-space: pre;"> </span>if (cell==&#39;STR&#39;) return &#39;3&#39;;</div>
<div><span style="white-space: pre;"> </span>}</div>
<div><span style="white-space: pre;"> </span>},</div>
<div><span style="white-space: pre;"> </span>{name:&#39;Name&#39;, index:&#39;Name&#39;, width:200, sorttype:"text"}</div>
<div><span style="white-space: pre;"> </span>]</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>});</div>
<div><span style="white-space: pre;"> </span>&#60;/script&#62;</div>
<div><span style="white-space: pre;"> </span>&#60;/head&#62;</div>
<div><span style="white-space: pre;"> </span></div>
<div><span style="white-space: pre;"> </span>&#60;body&#62;</div>
<div><span style="white-space: pre;"> </span>&#60;table id="playerTable"&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;thead&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;th&#62;Posn&#60;/th&#62;&#60;th&#62;Name&#60;/th&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;/thead&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tbody&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;td&#62;GK&#60;/td&#62;&#60;td&#62;Almunia&#60;/td&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;td&#62;GK&#60;/td&#62;&#60;td&#62;Fabianski&#60;/td&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;td&#62;DEF&#60;/td&#62;&#60;td&#62;Campbell&#60;/td&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;td&#62;DEF&#60;/td&#62;&#60;td&#62;Clichy&#60;/td&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;td&#62;MID&#60;/td&#62;&#60;td&#62;Denilson&#60;/td&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;td&#62;MID&#60;/td&#62;&#60;td&#62;Diaby&#60;/td&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;td&#62;STR&#60;/td&#62;&#60;td&#62;Arshavin&#60;/td&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;tr&#62;&#60;td&#62;STR&#60;/td&#62;&#60;td&#62;Bendtner&#60;/td&#62;&#60;/tr&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;/tbody&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;/table&#62;&#160;</div>
<div><span style="white-space: pre;"> </span>&#60;/body&#62;</div>
<div>&#60;/html&#62;</div>
<div></div>
]]></description>
        	        	<pubDate>Sat, 24 Jul 2010 12:13:53 +0300</pubDate>
        </item>
</channel>
</rss>