简体   繁体   中英

Kendo Grid Time Format Filtering

I got Local Json data is

var MYDATA=[{"StartTime":'19:00:12.000',"StartDate":'2014-02-11',"Name":"John"},
            {"StartTime":'20:09:15.000',"StartDate":'2014-02-11',"Name":"Alan"},
            {"StartTime":'20:22:22.000',"StartDate":'2014-02-11',"Name":"Liza"}
];

I make kendo grid has properities are sortable,groupable,filterable,reziable. When I Try to filter to StartTime , it is not working. Can I put schema model field type is time?

StartTime:{ type:time}

If I dont define StartTime field in to schema model . Kendo grid thinks "it is string".

I define it date then defined it in column below;

 { field: "StartTime", title: "Start Time" ,format: "{0:hh:mm:ss}", filterable: {
                    ui: "timepicker",

                }}

But Not filter or Show in my grid.

No, you have to put it a "date". Valid data types are: "string", "number", "boolean", "date". The default is "string".

Valid type can be found in here : http://docs.telerik.com/kendo-ui/api/framework/model#methods-Model.define

Example here: http://jsfiddle.net/OnaBai/B8G6X/

var MYDATA=[
    {"StartTime":'19:00:12.000',"StartDate":'2014-02-11',"Name":"John"},        
    {"StartTime":'20:09:15.000',"StartDate":'2014-02-11',"Name":"Alan"},
    {"StartTime":'20:22:22.000',"StartDate":'2014-02-11',"Name":"Liza"}
];

var ds = new kendo.data.DataSource({
    data : MYDATA,
    schema : {
        model : {
            fields : {
                StartTime : { type : "date" },
                StartDate : { type : "date" },
                Name : { type : "string" },
            }
        }
    },
    pageSize: 10
});

var grid = $("#grid").kendoGrid({
    dataSource: ds,
    editable  : false,
    sortable  : true,
    pageable  : true,
    columns   :
    [
        { field: "StartTime", title: "Time", format : "{0:HH:mm:ss}" },
        { field: "StartDate", title: "Date", format : "{0:yyyy-MM-dd}" },
        { field: "Name", width: 200 }
    ]
}).data("kendoGrid");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM