我使用 jqGrid 4.4.0 和 jQuery 1.7.2(我也尝试了最新版本的 jqgrid 和 jquery)。我像这样使用treegrid:
jQuery('#projects_grid').jqGrid({
treeGrid: true,
treeGridModel: 'adjacency',
ExpandColumn: 'ProjectName',
url: 'jqGridTestHandler.ashx?q=tree',
treedatatype: 'xml',
mtype: 'POST',
colNames: ['RID', l_('ProjectName'), l_('CustomerName'), l_('StartDate'), l_('EndDate'), l_('ManagerName'), l_('SourceLang'), l_('TargetLang'), l_('DomainName'), '', ''],
colModel: [
{ name: 'RID', index: 'RID', hidden: true, key: true },
{ name: 'ProjectName', index: 'ProjectName' },
{ name: 'CustomerName', index: 'CustomerName' },
{ name: 'StartDate', index: 'StartDate', width: '80px', align: 'center'},
{ name: 'EndDate', index: 'EndDate', width: '80px', align: 'center' },
{ name: 'FullName', index: 'FullName', align: 'center' },
{ name: 'SourceLang', index: 'SourceLang', width: '110px', align: 'center', formatter: flagFormatter },
{ name: 'TargetLang', index: 'TargetLang', width: '110px', align: 'center', formatter: flagFormatter },
{ name: 'DomainName', index: 'DomainName', width: '110px', align: 'center', formatter: domainNameFormatter },
{ name: 'IsExternal', index: 'IsExternal', hidden: true },
{ name: 'myac', fixed: true, sortable: false, resize: false, width: '30px'}],
height: '345px',
loaded: false,
shrinkToFit: false,
pager: '#projects_pager',
rowNum: 10,
autowidth: true,
rowList: [10, 20, 30],
viewrecords: true,
sortorder: 'desc',
altRows: true,
toolbar: [true, 'top'],
ExpandRowClick: true,
...some events (loadcomplete etc..)
我的数据源是这样的:
<?xml version='1.0' encoding='utf-8'?>
<rows>
<page>1</page><total>1</total><records>4</records>
<row>
<cell>B55A6056261913D62648F2730C2766B2</cell>
<cell>Test Projectname1</cell>
<cell>Test Customer</cell>
<cell>18.02.2013</cell>
<cell>28.02.2013</cell>
<cell>Frank</cell>
<cell>en-GB</cell>
<cell>tr-TR</cell>
<cell>Law</cell>
<cell>0</cell>
<cell>0</cell>
<cell>0</cell>
<cell><![CDATA[NULL]]></cell>
<cell>true</cell>
<cell>false</cell>
</row>
<row>
<cell>21142DEE531B2313FC9356C3B000B54D</cell>
<cell>Test Projectname2</cell>
<cell>Test Customer</cell>
<cell>05.04.2013</cell>
<cell>06.04.2013</cell>
<cell>Frank</cell>
<cell>en-GB</cell>
<cell>tr-TR</cell>
<cell>Law</cell>
<cell>0</cell>
<cell>0</cell>
<cell>0</cell>
<cell><![CDATA[NULL]]></cell>
<cell>true</cell>
<cell>false</cell>
</row>
<row>
<cell>5FF805CE71B0A459C83734735B990E8C</cell>
<cell>Test Projectname3</cell>
<cell>Test Customer</cell>
<cell>22.04.2013</cell>
<cell>27.04.2013</cell>
<cell>Frank</cell>
<cell>en-GB</cell>
<cell>tr-TR</cell>
<cell>Law</cell>
<cell>0</cell>
<cell>0</cell>
<cell>0</cell>
<cell><![CDATA[NULL]]></cell>
<cell>false</cell>
<cell>false</cell>
</row>
<row>
<cell>BCD36ABFA07CE94089F6C5B743C57608</cell>
<cell>Test Projectname4</cell>
<cell>Test Customer</cell>
<cell>27.04.2013</cell>
<cell>28.04.2013</cell>
<cell>Frank</cell>
<cell>en-GB</cell>
<cell>tr-TR</cell>
<cell>Law</cell>
<cell>0</cell>
<cell>0</cell>
<cell>0</cell>
<cell><![CDATA[NULL]]></cell>
<cell>true</cell>
<cell>false</cell>
</row>
</rows>
所以我的问题是日期列排序。我在stackoverflow中进行了一些搜索,我找到了一些解决方案,但它们对我的情况不起作用。
像这样的未排序列表:
18.02.2013
05.04.2013
22.04.2013
27.04.2013
排序如下:
05.04.2013
18.02.2013
22.04.2013
27.04.2013
我错了什么?