我有一个带有日期列的剑道网格。为了格式的日期,我使用的是:格式:{0: dd/MM/yyyy }
。
一切都很好,直到我尝试更新网格的数据源:
chargesDS.data(ko.toJS(newValue));
chargesDS.sync();
chargesGrid.refresh();
.data()调用(第一行)中断了日期列,导致格式恢复为默认格式。
有没有一种方法可以刷新网格,以便再次正确显示日期?
对于到这里结束的任何人:我通过使用模板解决了这个问题:
function KendoDateTemplate (dateFormat, propertyName) {
var temp =
"#= " + propertyName + " ?" + //is the date non-null? if yes, parse. If no, show empty string.
"kendo.toString(kendo.parseDate(moment(" + propertyName + ").toDate(), 'yyyy-MM-dd'), '" + dateFormat + "' ) " +
" : \"\" #"; //second half of tertiary exp
return temp;
};
...并在网格选项中:
{
field: "DateField", title: "Date",
template: KendoDateTemplate('MM/dd/yyyy', 'DateField')
}, ...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句