为什么剑道 Ui -grid 日期排序不正确? [英] Why kendo Ui -grid date is not sorting properly?

查看:16
本文介绍了为什么剑道 Ui -grid 日期排序不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

值为 ReinsDepositAmount

**

**

我最近在剑道 UI 网格中存放了一个应用程序日期排序.

I have recently stocked with one of the application date sorting in the kendo UI grid.

在kendo grid中,列名是这样定义的

In kendo grid, the column name is defined like this

ReinsDepositDate 的传入值 - 月、日、年格式.08-23-1991

Incoming value to ReinsDepositDate - Month,date,year format. 08-23-1991

字段名称是 ReinsDepositDate:

{
    field: "ReinsDepositDate", type: "date", title: "Due Date",format: "{0:M/d/yyyy}", width: 100, filterable: {
              cell: {
                   operator: "contains"  
                    }
            }
},

对日期进行排序时,根据第一个值进行排序

When Sorting the date, its sorting based on first values

  1. 1/12/1994
  2. 23/1/2015
  3. 13/1/1992

表示上升时我得到

  1. 1/12/1994
  2. 13/1/1992
  3. 23/1/2015

所以我已经把模式模型

仍然,我得到了相同的结果.

still, I am getting the same result.

 schema: {
                model: {
                    fields: {
                        ReinsDepositDate: { type: "date",format: "{0:dd/MM/yyyy}"}
                    }
                }
            },

我看过很多小提琴演示,但在这里没有任何作用,为什么:

I have seen lots of fiddle demos nothing works here why:

参考资料:http://fiddle.jshell.net/NqrDS/light/Kendo 网格日期列未格式化

设计流程:

设计流程是使用angular Http服务通过API从DB获取值并将响应分配给kendo网格中的数据源.当我用 JSON 文件做一个演示时,它工作正常.但同样的事情在这里适用它意味着不工作.所以我去自定义javascript进行排序.列:[$scope.grdPrmiumDepositCol, –

Flow of design is by using angular Http service get the value from DB through API and assign the response to datasource in the kendo grid. when I doing a demo with JSON files, its working fine. But the same thing applies it here means not working. so I went to custom javascript to sort. columns:[$scope.grdPrmiumDepositCol, –

kendo sortable 属性中的自定义 javascript 可以解决问题.这部分工作正常.

Custom javascript in kendo sortable attribute will do the trick. working fine do this part.

 { field: "ReinsDepositDate", format: "{0:MM/dd/yyyy}",type:"date",  sortable:{  compare: function (a, b) {
                           var c = new Date(a.ReinsDepositDate);
                            var d = new Date(b.ReinsDepositDate);
                            return c - d;
                        }`

                    }}],

我的问题是我为什么这样做,因为剑道被赋予了日期格式,当我尝试使用传输读取的示例演示时,JSON 文件在剑道格式下工作正常.还是一头雾水.

My Question is why I do that because kendo is given the date format and when I tried the sample demo with transport read with JSON file working fine with kendo format. Still in confusion.

推荐答案

根据提供的信息,不清楚是在客户端进行排序,还是在服务器端进行排序.

Based on the provided information, it is unclear if sorting is performed on the client, or on the server.

如果排序是由 Kendo UI 数据源在客户端完成的,那么日期值应该以正确的格式提供,以便它们被 Kendo UI 解析为 JavaScript 日期对象.有多种不同的格式可以解析,但dd-MM-yyyy不是其中之一.

If sorting is done on the client by the Kendo UI DataSource, then the date values should be provided in the correct format, so that they are parsed to JavaScript Date objects by Kendo UI. There are multiple different formats that can be parsed, but dd-MM-yyyy is not one of them.

这是一个示例,它演示了上述内容.您会注意到未解析日期的空行.

Here is an example, which demonstrates the above. You will notice the empty row, where the date has not been parsed.

http://dojo.telerik.com/UcEXO/2

通常,建议使用普遍接受的标准对日期进行序列化:

Generally, it is recommended to serialize dates using commonly accepted standards:

https://stackoverflow.com/a/15952652/3086237

如果排序是在服务器端进行的,那么Kendo UI与问题无关,你应该调试服务器端的实现.

If sorting is performed on the server, then Kendo UI is unrelated to the problem and you should debug the server-side implementation.

这篇关于为什么剑道 Ui -grid 日期排序不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆