开发者

Does jqGrid support milliseconds in "datefmt"?

One of my columns contains dat开发者_JAVA百科es and is sortable. I unsuccessfully tried to use datefmt: 'dd/mm/yyyy hh:mm:ss.sss' and d/m/Y H:i:s.u in the column model to describe to jqGrid how to sort the column.

An example of the actual data to be sorted is 07/10/2011 03:08:32.454.

Of course, the column's sorttype is 'date'.


I suggest you to post date/time information in some non-localized format. For example in this one:

2011-05-29T23:36:41.1470055+02:00

Such date format is already sortable. To convert myDate variable of the DateTime in the format you can use under .NET the "o" foratter:

myDate.ToString ("o", new CultureInfo ("en-us", true))

To display the date in the 'dd/mm/yyyy hh:mm:ss.sss' format you can use about the following custom formetter:

formatter: function (cellvalue, options, rowObject) {
    var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
                 "(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
                 "(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?",
        d = cellvalue.match(new RegExp(regexp));
    return d[5] + '/' + d[3] + '/' + d[1] + ' ' + d[7] + ':' + d[8] + ':' + d[10] +
          '.'+ d[12];
}


I reported this as a bug in jqGrid, and it will be fixed in the next release.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜