Date 剑道网格日期格式数据源
我有一个剑道网格和一个日期列。为了设置日期格式,我使用: 格式:Date 剑道网格日期格式数据源,date,kendo-ui,grid,datasource,Date,Kendo Ui,Grid,Datasource,我有一个剑道网格和一个日期列。为了设置日期格式,我使用: 格式:{0:dd/MM/yyyy} 一切正常,直到我尝试更新网格的数据源: chargesDS.data(ko.toJS(newValue)); chargesDS.sync(); chargesGrid.refresh(); .data()调用(第一行)中断日期列,导致格式返回到某个默认格式 有没有办法刷新网格,以便
{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')
}, ...