This is a migrated thread and some comments may be shown as answers.

Change format and decimals at runtime

4 Answers 888 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Volker
Top achievements
Rank 1
Volker asked on 10 Feb 2014, 01:52 PM
Hi,

I am building an app with a grid, where numeric-textboxes are used as edit-controls when someone edits the numbers in the grid.

I implemented that the numeric textbox in one row cannot have a value greater than the row before, i.e. when the grid creates the edit-control I changed the minx/max etc. of the numeric textbox.

The only thing I cannot change so far is the format and the decimals. Can I somehow also change that dynamically? The problem is I do not know the format/decimals when loading the page...

Thanks in advance,
Volker

4 Answers, 1 is accepted

Sort by
0
Volker
Top achievements
Rank 1
answered on 10 Feb 2014, 06:59 PM
Ok, doing some further research, I found this way of setting the options:

editElement.kendoNumericTextBox.setOptions({format: "#.#", decimals: 1 });


Not documented it seems, but it works. Is there an "official" way of doing this? I already had compatibility issues when exchanging Kendo versions, so I do not want to create another problem...

Thanks!
0
Volker
Top achievements
Rank 1
answered on 10 Feb 2014, 07:08 PM
Ok, forget what I said... does not work, I just did not see the exception that is thrown... :(
0
Georgi Krustev
Telerik team
answered on 11 Feb 2014, 08:36 AM
Hello Volker,

Indeed the setOptions method of the NumericTextBox widget is not document. We will address this immediately.

As to how to use the setOptions method, you will need to get the instance of the DatePicker object. You can find more information here how to do this. Check this online demo, which uses the setOptions method to dynamically change settings of the widgets.


Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Volker
Top achievements
Rank 1
answered on 12 Feb 2014, 06:06 PM
Ok, the code from me above was wrong (in accessing the numeric textbox). This one should do it:

editElement.data("kendoNumericTextBox").setOptions({format: "#.#", decimals: 1 });
Tags
NumericTextBox
Asked by
Volker
Top achievements
Rank 1
Answers by
Volker
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or