【发布时间】:2015-10-07 12:06:13
【问题描述】:
我正在使用 Knockout.js 与 Kendo UI Grid (http://rniemeyer.github.io/knockout-kendo/web/Grid.html) 的集成。
在我的 JSON 中,我返回的日期显示为 Oct 06 2015, 03:54 PM -04:00。
我已将列类型和格式指定为格式:"{0:MM/dd/yyyy HH:mm tt}",但它似乎被完全忽略了。
以下是kendogrid绑定定义:
<div data-bind="kendoGrid: {
data: projectSubmissions,
dataSource: {
schema: {
model: {
fields: {
SubmissionId: { type: 'number' } ,
FormName: { type: 'string' } ,
IdVersion: { type: 'string' },
SubmittedDateFormatted: { type: 'string'},
SubmittedDate: { type: 'date'},
}
}
}
},
groupable: false,
scrollable: false,
filterable: {
extra: false,
operators: {
string: {
startswith: 'Starts with',
eq: 'Is equal to',
neq: 'Is not equal to'
}
}
},
sortable: true,
pageable: { pageSize: 10 },
columns: [
{
field: 'SubmissionId',
title: 'No.',
width: 70,
}
,{ field: 'FormName', title: 'Form', width:120 }
,{ field: 'IdVersion', title: 'Id/Version', width:100}
,{
field: 'SubmittedDate',
filterable: true,
title: 'Submitted Date',
format: '{0:MM/dd/yyyy HH:mm tt}',
width: 120
}
,{ field: 'Inspector', title: 'Inspector', filterable: true, width:140 }
,{ field: 'CellNo', title: 'Cell No.', width:100, filterable: false }
]
}"></div>
【问题讨论】:
-
您的代码中有错字:
''{0:MM/dd/yyyy HH:mm tt}',您在使用格式之前使用了两个引号。 -
谢谢 - 我已修复(这只是粘贴样本时的错误)
-
你如何解析你的json?
-
我正在使用 ko.mapping.fromJS(data, {}, this);来执行映射。结果属性看起来像 "SubmittedDate": "2015-10-06T15:54:02.047",
-
我也无法让过滤器 UI:datepicker 工作,我希望这些问题能够得到解决
标签: knockout.js kendo-grid knockout-kendo