Hey there,
I have a grid and for several columns I have the data type set as numeric. The filtering works great it allows numbers only positive and negative. Perfect, but my client just discovered that if you hit up and down arrow keys it will auto increment the values. They would like to disable this feature but I haven't found a method to do just that. I could switch the data type to text, but then I'd lose all masking that the numeric editor provides.
Any ideas?
Thanks,
This is still an open issue. Anyone have any work arounds?
Try this. var base = { _spin: $.ui.igEditor.prototype._spin };
$.extend(true, $.ui.igNumericEditor.prototype, { _create: function(s) { this.options.spinEnabled = false; var extendedEditor = base._createEditor.apply(this, arguments); } });
$.extend(true, $.ui.igEditor.prototype, { _spin: function(j) { if (this.options.spinEnabled) { base._spin.apply(this, arguments); } } });
That worked. I would not have figured this one out anytime soon. Many thanks!
I did have to wrap it in a try/catch statement because refreshing the page did invoke a prototype not recognized exception. Other then that, it works perfectly!
Yeah let me create a small prototype with one. My grids are way to big to use. Most of mine focus on row templating and most of my row templates stretch for miles. But Infragistics handles them like a champion.
Daniel Dority said: What is the different between self executing and the way I have it implemented?
Yours runs on document.ready. Mine runs before hand. Interesting that it doesn't work for me in the grids....I'll have to take a look. Can you post your grid code?
The first option worked for controls in the grid.
I have the code in the initialize jQuery code.
$(function () {
// Your code
});
And it will throw an error whenever. What is the different between self executing and the way I have it implemented?
Daniel Dority said:I did have to wrap it in a try/catch statement because refreshing the page did invoke a prototype not recognized exception. Other then that, it works perfectly!
You shouldn't need to do that. Just wrap it in a self executing function like so:
(function ($) { var base = { _spin: $.ui.igEditor.prototype._spin }; $.extend(true, $.ui.igEditor.prototype, { _spin: function (j) { if (!this.options.spinDisabled) { base._spin.apply(this, arguments); } } }); })(jQuery);
I've modified my usage of this, and you may want to do the same, so that if you ever want the spin, you don't have to explicitly enable it. Just reverse the logic.
Replace this.options.spinEnabled = false with this.options.spinDisabled = true
and then test for it like so: if(!this.options.spinDisabled){
//call apply
}
Glad I could help. Also, if you using editors in a grid, this won't work. They initialize differently (which sucks, IMO) and you'll have to find another hook to duck punch.
-b