Kendo UI Numerictextbox Positive and Negative format

Here is how I workaround it. I need + to be shown when positive. any of this logic applied to your needs, just change accordingly.

Unfortunately they don’t support this add the moment, here is how I workaround it

   1: $(function () {
   2: // bind to the change event
   3:   rsph.bind("change", viewModel.SphereChanged);
   4:   lsph.bind("change", viewModel.SphereChanged);
   5:   $('#rsph').focus(viewModel.SphereFocus);
   6:   $('#lsph').focus(viewModel.SphereFocus);
   7: }
   8: var viewModel = kendo.observable({
   9: SphereFocus: function (e) {
  10:      $(this).removeClass('indentedpositive');
  11:      $(this).parent().find('.k-formatted-value').removeClass('indentedpositive');
  12:      $(this).parent().find('.positivesign').remove();
  13:  },
  14:  SphereChanged: function (e) {
  15:  
  16:      var value = e.sender._value;
  17:      var id = $(e.sender.element).attr('id');
  18:      if (value > 0) {
  19:          $('#' + id).addClass('indentedpositive');
  20:          $(e.sender.element).parent().find('.k-formatted-value').addClass('indentedpositive');
  21:          $(e.sender.element).parent().prepend('<div class="positivesign">+</div>');
  22:      } else {
  23:          $('#' + id).removeClass('indentedpositive');
  24:          $(e.sender.element).parent().find('.k-formatted-value').removeClass('indentedpositive');
  25:          $(e.sender.element).parent().find('.positivesign').remove();
  26:      }
  27:  }
  28: });
Share this post: | | | |
Published Friday, August 10, 2012 3:24 PM by cipto

Comments

No Comments