2

我正在用 Jquery 使用 Kendo Grdi。该网格有 DateTime 列。该列中的数据显示为 "/Date(1377196200000)/" 。帮我把它安排成正确的格式。

这是我的网格脚本;

函数加载网格视图(){

var dataSource = GetDataSource();

$("#batchgrid").kendoGrid({
    dataSource: dataSource,
    editable: "inline",
    selectable: "row",
    toolbar: ["create"],
    autobind: true,
    reorderable: true,
    pageable: {
        refresh: true,
        pageSizes: [5, 10, 20, 50, 100]
    },
    sortable: {
        mode: "multiple"
    },
    sort: { field: "PrjNm", dir: "asc" },
    groupable: {
        messages: {
            empty: "Drop columns here"
        }
    },
    columnMenu: {
        sortable: true,
        filterable: true,
        messages: {
            columns: "Hide/Show Columns",
            filter: "Apply filter",
            sortAscending: "Sort (asc)",
            sortDescending: "Sort (desc)"
        }
    },
    resizable: true,
    dataBinding: function () {
        record = (this.dataSource.page() - 1) * this.dataSource.pageSize();
    },
    filterable: {
        messages: {
            and: "And",
            or: "Or",
            filter: "Apply filter",
            clear: "Clear filter",
            info: "Filter by"
        },
        extra: false, //do not show extra filters
        operators: { // redefine the string operators
            string: {
                contains: "Contains",
                doesnotcontain: "Doesn't contain",
                startswith: "Starts With",
                endswith: "Ends"
            },
            number: {
                eq: "Is Equal To",
                neq: "Not equal to",
                gte: "Greater than or equal to",
                lte: "Less than or equal to",
                gt: "Greater than",
                lt: "Less than"
            }
        }
    },
    navigatable: true,
    columns: [
                    { title: "No", template: "#= ++record #", width: 45 },
                    { field: "ItemCode", title: "Item Code", width: "150px" },
                    { field: "ItemName", title: "Item Name", format: "{0:c}", width: "300px" },
                    { field: "PreviousDate", title: "Previous Date", type: "date", format: "{0:dd/MM/yyyy}" },
                    { field: "PreviousValue", title: "Previous %", width: "110px", format: "{0:2}" },
                    { field: "Value", t`enter code here`itle: "%", width: "150px", format: "{0:2}" },
    { command: ["edit"], title: " ", width: "175px" }
    ]
});

}

4

1 回答 1

2

确保您的DataSource在模型中正确定义日期字段类型(如日期),如下所示:

model: {
    fields: {
        PreviousDate: { type: "date" },
            }
       }
于 2013-08-23T10:36:03.253 回答