0

私はjqGrid 4.4.0とjQuery 1.7.2を使用しています(最新バージョンのjqgridとjqueryも試しました)。私はそのようにツリーグリッドを使用します:

    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

私は何を間違っていますか?

4

1 に答える 1

0

formatter: "date"正しいformatoptionsin'StartDate'および'EndDate'列で使用する必要があります。現在の設定 (デフォルト オプション) は、データを文字列として解釈するよう jqGrid に通知します。次のような形式で日付を正しく並べ替えるには22.04.2013、列の定義に次の追加のプロパティを含める必要があります。

formatter: "date", formatoptions: { srcformat: "d.m.Y", newformat: "d.m.Y" }
于 2013-06-20T08:07:58.723 に答える