Knockout-Kendo.js网格UI:datepicker过滤器 [英] Knockout-Kendo.js Grid UI:datepicker filter

查看:263
本文介绍了Knockout-Kendo.js网格UI:datepicker过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Knockout-Kendo.js 集成库
我试图让datepicker过滤器工作。但是,每当我添加过滤器:{ui:datetimepicker}到我的配置没有什么显示在页面上,没有脚本错误。

I am using the Knockout-Kendo.js integration library I am trying to get the datepicker filter working. However, whenever I add filterable: {ui: "datetimepicker" } to my configuration nothing is shown on the page and no script errors.

我的kendoGrid配置看起来像在SubmitDate上具有可过滤属性)

My kendoGrid configuration looks like (here with filterable attribute on SubmittedDate)

            <div data-bind="kendoGrid: {                     
               data: projectSubmissions,
                dataSource: {                        
                    schema: { 
                        model: { 
                                fields: { 
                                            SubmissionId: { type: 'number' } ,
                                            FormName: { type: 'string' } ,
                                            IdVersion: { type: 'string' },
                                            SubmittedDateFormatted: { type: 'string'},
                                            SubmittedDate: { type: 'date'},
                                            Inspector: { type: 'string'},
                                            CellNo: { type: 'string'},
                                        } 
                               } 
                    }    
                },                  
                groupable: false, 
                scrollable: false,   
                filterable: {
                            extra: false,
                            operators: {
                                string: {
                                    startswith: 'Starts with',
                                    eq: 'Is equal to',
                                    neq: 'Is not equal to'
                                }
                            }
                        },       
                sortable: true, 
                pageable: { pageSize: 10 },
                columns: [  {
                                field: 'SubmissionId',
                                template: '<a href=\'#=DetailUrl#\' target=\'blank\'>#=SubmissionId#</a>' ,
                                title: 'No.',
                                width: 30    
                            }  
                            ,{ field: 'FormName', title: 'Form', width:120 }  
                            ,{ field: 'IdVersion', title: 'Id/Version', width:100}
                            ,{
                                   field: 'SubmittedDateFormatted',
                                   format: '{0:MM/dd/yyyy}',                                       
                                   title: 'Submitted Date',                                                       
                                   width: 120
                             }
                            ,{
                                field: 'SubmittedDate',
                                format: '{0:MMM dd yyyy, h:mm:ss tt zzz}',                                    
                                filterable: true,
                                title: 'Submitted Date',
                                width: 120,
                                filterable: {
                                ui: "datetimepicker"
                                }
                            }
                            ,{ field: 'Inspector', title: 'Inspector', filterable: true, width:140 }
                            ,{ field: 'CellNo', title: 'Cell No.', width:100, filterable: false }
                        ]
        }"></div>


推荐答案

我认为可能是由格式错误的日期字符串在 SubmittedDate 中。
尝试使用它:

I think that may be caused by wrong formatted date string in SubmittedDate. Try to use this instead:

filterable: {
            cell: {
                template: function (args) {
                    args.element.kendoDatePicker({
                        format: "MM dd yyyy, h:mm:ss tt zzz",
                        parseFormats: ["MM dd yyyy, h:mm:ss tt zzz"]
                    });
                }
            }
        }

如果您有时区在您的日期字符串中,尝试以 kendo datasource 中的所有日期://ru.wikipedia.org/wiki/ISO_8601rel =nofollow> iso 8601 ):

If you have a time zone in your date string, try to convert all dates in datasource in correct format for kendo (iso 8601):

dateToLocalUTCString = function (date, isUtc) {
    var pad = function (number) {
        var r = String(number);
        if (r.length === 1) {
            r = '0' + r;
        }
        return r;
    }
    return date.getFullYear()
        + "-" + pad(date.getMonth() + 1)
        + "-" + pad(date.getDate())
        + "T" + pad(date.getHours())
        + ":" + pad(date.getMinutes())
        + ":" + pad(date.getSeconds())
        + "." + String((date.getMilliseconds() / 1000).toFixed(3)).slice(2, 5)
        + (isUtc ? "Z" : "");
};

这篇关于Knockout-Kendo.js网格UI:datepicker过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆