问题描述
我无法确定要与Kendo Grid一起解析的日期.我正在使用Knockout-Kendo来协助进行数据绑定.
I am having trouble getting a date to parse with the Kendo Grid.I am using Knockout-Kendo to assist with the data-bindings.
我尝试解析的json响应中的日期字符串看起来像2012-03-13T00:00:00
.
The date-string in the json response that I am attempting to parse looks something like2012-03-13T00:00:00
.
Kendo网格的列定义包含format: '{0:MM/dd/yyyy}'
,它似乎可以在另一个不使用Knockout-Kendo解析完全相同的日期字符串的网格上使用.
The column definition for the Kendo grid contains format: '{0:MM/dd/yyyy}'
which seems to work on another grid that isn't using Knockout-Kendo to parse the exact same date string.
我创建了一个jsFiddle(很好地重复使用了一个单独的问题),该jsFiddle演示了此问题完全在此处.
I have created (well re-using from a separate question) a jsFiddle that demonstratesthe issue fully here.
我只想避免使用行模板,因为我还没有弄清楚如何正确地将它们设置在敲除绑定中,但是我完全可以接受替代或完全正确"的建议.
I want to stay away from row-templates only because I haven't figured out how to correctly set them up in a knockout binding, but I am completely open to alternative or "just correct" suggestions.
推荐答案
可以在配置中指定dataSource
.您仍然需要指定data
键,因此绑定知道您正在传递选项,而不仅仅是直接传递数据.
It is possible to specify a dataSource
in the configuration. You do need to still specify a data
key, so the binding know that you are passing options and not just the data directly.
可以看起来像:
<div id="grid" data-bind="kendoGrid: {
data: undefined,
dataSource: {
data: SaleSearchResults,
schema: { model: { fields: { SaleDate: { type: 'date' } } } }
},
此处更新了小提琴: http://jsfiddle.net/rniemeyer/EUFxg/
这篇关于无法使用KendoUI Grid和Knockout-Kendo格式化日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!