Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date 剑道网格日期格式数据源_Date_Kendo Ui_Grid_Datasource - Fatal编程技术网

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')
}, ...