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

How to format comboBox values?

1 Answer 488 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 14 Feb 2013, 09:54 PM
Is there way to format the values and input field of the ComboBox widget?

Essentially I'd like a merged combobox/numeric textbox...

1 Answer, 1 is accepted

Sort by
1
Alexander Valchev
Telerik team
answered on 18 Feb 2013, 02:54 PM
Hello Alexander,

ComboBox widget does not support formatting out of the box. If you want to achieve such behaviour you may hook up to the change event of the ComboBox and format the value manually. As an example:
<input id="combo" />
<script>
    $("#combo").kendoComboBox({
        change: function (e) {
            var value = parseFloat(this.value()); //parse value
 
            if(!isNaN(value)) { //if is number
                value = kendo.format("{0:n2}", value); //format it
                this.value(value); //set it as a value
            } else {
                this.value(""); //clear the value
            }
        }
    })
</script>

I hope this information will help.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ComboBox
Asked by
Alexander
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or