对 jqGrid 中的日期列进行排序

Bha*_*ani 3 javascript jquery jquery-ui jqgrid

我正在使用jqGrid在用户界面中显示记录,并且我想对日期列进行排序。它以 的形式返回我的日期Sat, Sep 1, 01:41 AM。我怎样才能用 jqGrid 做到这一点?

我对该专栏的 Colmodel 是:

{name:'transactiontime', index:'transactiontime',  sorttype:'text', align:"right"},
Run Code Online (Sandbox Code Playgroud)

Ole*_*leg 5

尝试以下操作formatoptions

{name: 'transactiontime', sorttype: 'date', align: "right", formatter: 'date',
    formatoptions: {srcformat: 'ISO8601Long', newformat: 'D, M d, H:i A'}}
Run Code Online (Sandbox Code Playgroud)

请参阅演示,这是对答案中演示的简单修改。

srcformat可能取决于数据的输入格式。

  • @BhavikAmbani:我不喜欢有人给我写信“尽快回复”。我现在在另一个国家的客户那里,他们为我所做的咨询工作支付费用(与 jqGrid 无关)。所以我无法为世界各地的其他人提供支持。然而,您可能需要实现**自定义排序**:使用“sorttype”作为函数。请参阅[答案](http://stackoverflow.com/a/5296935/315935) 中的演示。 (2认同)