2016-02-17 128 views
0

我對kendo網格上的自定義過濾器,但在這裏我有一個小問題,當我在網格中的日期列我想限制用戶在過濾器輸入中輸入任何內容,預期的行爲是用戶應該始終從datepicker選擇應用過濾器的日期。如何將onkeydown函數應用於過濾器?如何限制用戶輸入劍道過濾器輸入?

config.js

getallCycles: { 
     sortable: true, 
     scrollable: true, 
     editable: false, 
     dataBound: function() { 
     }, 
     filterable:{ 
      extra: false, 
      operators: { 
       string: { 
        startswith: 'Starts with', 
        eq: 'Is equal to', 
        contains: 'Contains' 
       } 
      } 
     }, 
columns: [ 
{ 
      field: 'assessmentDueDate', 
      title: 'Cycle Assessments Due Date', 
      width: '190px', 
      filterable: { 
       ui: function (element) { 
        'use strict'; 
        element.kendoDatePicker({ 
         format: 'yyyy-MM-dd' 
        }); 
        element.onkeydown({ 
        return false; 
        }); 
       }, 
       operators: { 
        string: { 
         eq: 'Is equal to' 
        } 
       } 
      } 
      }, 
] 
} 

回答

1

您可以禁用屬性輸入控件添加禁用打字

filterable: { 
    ui: function(element) { 
    element.kendoDateTimePicker(); // initialize a Kendo UI DateTimePicker 
    $(element).attr("disabled","disabled"); 

    } 
} 

請參閱現場演示here

+0

非常感謝它的工作! – aftab