One of my date time format column in jqGrid is in following format:
1 November 2030, Fri 11:59pm.
How do I implement default sorting in ascending order in my below colModel?
colModel: [
{ name: 'startDate', width: 30},
]
Thanks.
Your demo use srcformat: "ISO8601Long"
, which means the format of inpuf data like "2030-11-01T23:59:00Z"
but not "1 November 2030, Fri 11:59pm"
, which you use.
jqGrid can safe parse the input date which contains numbers only. Parsing of inputs, which contains texts like Fri
is not work. I suggest you to change the format of input data. Only if you really can't change the format of input data then you can fix the problem by usage sorttype
defined as function
{
name: 'startDate', width: 60,
sorttype: function (cellValue) {
return moment(cellValue, "D MMMM YYYY, ddd h:mm a").format();
}
}
the above code use momentjs to parse the dates and replace there to ISO 8601 date format. The ISO dates will be used by jqGrid instead of original dates during sorting.