John
John

Reputation: 836

How to set TimePicker global interval in KendoUI?

I use KendoUI with AngularJS. Please help to set TimePicker globally interval in KendoUI. I can't find method to do this. By default, interval is set to 30 min.

Upvotes: 1

Views: 1118

Answers (1)

Shaan
Shaan

Reputation: 11436

You can set the interval using k-interval attribute. And load the value from your controller.

Check this JSBin

  angular.module("KendoDemos", [ "kendo.directives" ])
      .controller("MyCtrl", function($scope){
          $scope.getType = function(x) {
              return typeof x;
          };
          $scope.isDate = function(x) {
              return x instanceof Date;
          };
          //one setting for controller, or you can set this using angular constant to be used in multiple controllers.  
          $scope.timeInterval = 15;
      })

And in your view

 <input kendo-time-picker
             ng-model="str"
             k-ng-model="obj" k-interval="timeInterval" />

EDIT:

To update the interval of all the kendo time pickers, you can do the following.

 kApp.run(function($rootScope) {    

    $rootScope.$on("kendoWidgetCreated", function(event, widget){

      //get the element
      var elem = widget.element[0];    
      //get the kendoTimePicker.
      var tPicker = $(elem).data("kendoTimePicker");
      if(tPicker)
        tPicker.timeView.options.interval = 15;
  });

Link to JSBin with edit

Upvotes: 1

Related Questions