Change format and decimals at runtime

5 posts, 0 answers
  1. Volker
    Volker avatar
    22 posts
    Member since:
    Jul 2013

    Posted 10 Feb 2014 Link to this post

    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
  2. Volker
    Volker avatar
    22 posts
    Member since:
    Jul 2013

    Posted 10 Feb 2014 in reply to Volker Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Volker
    Volker avatar
    22 posts
    Member since:
    Jul 2013

    Posted 10 Feb 2014 in reply to Volker Link to this post

    Ok, forget what I said... does not work, I just did not see the exception that is thrown... :(
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 11 Feb 2014 Link to this post

    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!
  6. Volker
    Volker avatar
    22 posts
    Member since:
    Jul 2013

    Posted 12 Feb 2014 in reply to Georgi Krustev Link to this post

    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 });
Back to Top
Kendo UI is VS 2017 Ready