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

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

问题描述

值为ReinsDepositAmount

**

** 我最近在kendo ui网格中坚持使用一种应用程序日期排序.

** i have recently stucked with one of the application date sorting in kendo ui grid.

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

In kendo grid , the column name is define like this

ReinsDepositDate的传入值-月,日期,年格式. 1991年8月23日

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

字段名称为ReinsDepositDate: { 字段:"ReinsDepositDate",类型:"date",标题:"Due Date",格式:"{0:M/d/yyyy}",宽度:100,可过滤:{ 细胞: { 运算符:包含"
} } }

Field name is 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. 1994年1月12日
  2. 2015年2月1日
  3. 13/1/1992

是指我得到提升时

  1. 1994年1月1日 1992年1月23日
  2. 2015年2月1日
  1. 1/12/1994 2.13/1/1992
  2. 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网格日期列未格式化

设计流程:

设计流程是通过使用角度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 kendo grid. when i doing a demo with json files , its working fine. But same thing apply 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;
                        }`

                    }}],

我的问题是为什么我这样做,因为kendo给出了日期格式,并且当我尝试通过json文件与kendo格式一起正常工作的示例演示进行传输读取时.仍然很困惑.

My Question is why i do that because kendo 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 Date对象.可以解析多种不同的格式,但是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.

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

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