2017-06-28 86 views
1

我正在使用具有datetimepicker作爲每行中的列的kendo網格。如何使用AngularJs在KendoDateTimePicker中設置日期選擇器的最小/最大值使用AngularJs

datetimepicker應該只允許用戶選擇昨天和今天的日期和時間是靈活的。

我試過很多方法,但是我無法完成。

我的網格列是 -

{ field: "Fac", title: "Fac Name", width: "100px", editor: $scope.facDropDownEditor, template: "#=(FacFacyName==null)? '' : Fac.FacName #" }, 
 
      { field: "RecordedDate", title: "Date - Time", format: "{0:yyyy-MM-dd HH:mm}", editor: dateTimeEditor, width: "100px" }, 
 
      { field: "Remarks",title:"Remarks",width:"120px"}, 
 
     { field: "Volume", title: "Volume", width: "100px" }, 
 
    { 
 
     command: [ 
 
      { 
 
       name: "edit", title: "Edit", "template": "<a class='k-button k-grid-edit' href='' style='min-width:40px;' title=\"Edit\"><span class='k-icon k-i-edit'></span></a>" 
 
      }, 
 
     ], field: "Actions",title:"Actions", width: "60px" 
 
    }

我datetimeEditor是 -

function dateTimeEditor(container, options) { 
 
    $('<input data-text-field="' + options.field + '" data-value-field="' + options.field + '" data-bind="value:' + options.field + '" data-format="' + options.format + '"/>') 
 
      .appendTo(container) 
 
      .kendoDateTimePicker({}); 
 
}

如何編輯日期選擇器,這樣我只能得到今天和昨天的日期可選

+0

到這裏看看: http://demos.telerik.com/kendo-ui/datepicker/disable-dates 反向這一點,所以你只能選擇上定義的,應該是很簡單的具有可選日期數組。 – Adriani6

+0

http://docs.telerik.com/kendo-ui/controls/editors/datepicker/how-to/AngularJS/range-selection。我希望你可以按照例子使用k-min和k-max。 –

+0

最大日期是工作正常,但我沒能得到MINDATE截至昨日 –

回答

0

希望這會有所幫助!

function dateTimeEditor(container, options) { 
     $('<input data-text-field="' + options.field + '" data-value-field="' + options.field + '" data-bind="value:' + options.field + '" data-format="' + options.format + '"/>') 
       .appendTo(container) 
       .kendoDateTimePicker({ 
        max:new Date();//todays day 
        var yestarday= new Date(); 
        yestarday.setDate(dt.getDate() - 1); 
        min:yestarday;//yestardays date 
      }); 
} 
+0

也有一些是錯誤的語法,它給人的錯誤,同時輸入該代碼 –

+0

'kendoDateTimePicker({ 最大:新的Date(), // VAR yestarday =新日期(); //yestarday.setDate(dt.getDate() - 1); // 分鐘:yestarday; });以這種方式' 分鐘日期作品 –

相關問題