gpt4 book ai didi

javascript - 单击 dojo 网格标题的日期排序

转载 作者:行者123 更新时间:2023-11-29 14:52:28 25 4
gpt4 key购买 nike

我正在尝试对 dojo 网格中的日期进行排序。但是排序没有正确发生,它将日期视为字符串并且排序不起作用。有什么可以帮助我的吗?

我的日期格式:EE MMM dd yyyy HH:mm:ss z

我的代码:

myStore =  new ItemFileWriteStore({ 
data:storeData
});
myStore.comparatorMap = {};

myStore.comparatorMap["scan_date"] = function(a,b){
var af = dojo.date.locale.parse(a,{datePattern:"dd/MM/yyyy hh:mm:ss",selector:"date"});
var bf = dojo.date.locale.parse(b,{datePattern:"dd/MM/yyyy hh:mm:ss",selector:"date"});

var c = dojo.date.compare(af, bf);
return c;
}
// myStore.comparatorMap = {};
// myStore = new ObjectStore({ objectStore:new Memory({ data: data }) });
grid = new DataGrid({
store: myStore,
query: { id: "*" },
queryOptions: {},
structure: [
{ type: "dojox.grid._RadioSelector" },
[
// {name:'S.No.', field: 'Id', width: '47px'},
{name:"Client Name",field:"client_name",width: "auto"},
{name:"Contractor Name",field:"contractor_name",width: "auto"},
{name:"Barcode Number",field:"barcode_number",width: "auto"},
{name:"Replacement Seal Number",field:"container_number",width: "auto"},
{name:"Container Number",field:"container_no",width: "auto"},
{name:"Address",field:"address",width: "auto"},
{name:"Scan Date & Time",field:"scan_date",datatype:"date",width: "auto",formatter:formatDate},
{name:"Contractor Remarks",field:"contractor_remarks",width: "auto"}
]
]
}, "grid");
grid.startup();
});

最佳答案

因为你的日期格式是

EE MMM dd yyyy HH:mm:ss z

你可能需要改变你的,

dojo.date.locale.parse(a,{datePattern:"dd/MM/yyyy hh:mm:ss",selector:"date"});

具有如下所示的正确日期格式,

dojo.date.locale.parse(a,{datePattern:"EEE MMM dd yyyy HH:mm:ss Z",selector:"date"});

关于javascript - 单击 dojo 网格标题的日期排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23356820/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com