Kendo UI Grid weird issues with sorting DateTime

时间:2016-08-31 18:49:47

标签: javascript kendo-ui kendo-grid

The Issue I am seeing is that not all the data is being sorted correctly in this instance it looks like it is ignoring the AM / PM and is sorting strictly off the numerical value of the hours minutes and seconds. I have also attached a snippet of code below is there something I need to do differently or is this possibly a Kendo UI bug

Image displaying date issue

{
  title : "Start Date",
  field : "startDate",
  width : 150,
  template : "#= (startDate==null? '': kendo.toString(new Date(startDate),'MM/dd/yyyy hh:mm tt')) #",
  format : "{0: MM/dd/yyyy hh:mm tt}",
  filterable : {
                 ui : "datetimepicker"
               }
},
{
  title : "Error Date",
  field : "errorDate",
  width : 150,
  template : "#= (errorDate==null? '': kendo.toString(new Date(errorDate),'MM/dd/yyyy hh:mm tt')) #",
  format : "{0: MM/dd/yyyy hh:mm tt}",
  filterable : {
               ui : "datetimepicker"
               }
}

1 个答案:

答案 0 :(得分:0)

Kendo UI DataSource小部件对数据中存在的实际值执行过滤和排序(即不在Grid网格单元格中的数据可视化表示上)。

提供的屏幕截图和代码表明startDateerrorDate不是实际的JavaScript日期,否则无需为其调用new Date()

如果这些字段值不是真的Date对象,那么它们就不能这样排序,并且当前可能被排序为字符串。

以下主题提供了有关如何确保DataSource保存实际JavaScript Date对象的更多信息。

Why kendo Ui -grid date is not sorting properly?