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

NumericTextBox in Client Template

3 Answers 539 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dina
Top achievements
Rank 1
Dina asked on 20 Dec 2016, 05:34 PM

For some reason I can use TextBoxFor in client template but cannot NumericTextBox

 

For ex. I have EditorTemplate

@Html.Kendo().TextBoxFor(m => m.Floor).HtmlAttributes(new { style = "width:100%;" }).ToClientTemplate()

Is absolutely fine

But

@Html.Kendo().NumericTextBoxFor(m => m.Sqm).HtmlAttributes(new { style = "width:100%;" }).ToClientTemplate()

generate "invalid template"

 

Here is what I extracted from error

<input data-val="true" data-val-number="The field Площадь must be a number." data-val-required="The Площадь field is required." id="Sqm" name="Sqm" style="width:100%;" type="number" value="" /><script>jQuery(function(){jQuery("#Sqm").kendoNumericTextBox({});});</script>    </p>' Generated code:'var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='<input data-val="true" data-val-required="The ApartmentId field is required." id="ApartmentId" name="ApartmentId" type="hidden" value="" /><div class="k-edit-label">    <label for="Number">Номер</label></div><div class="editor-field">    <input class="k-textbox" data-val="true" data-val-required="Укажите номер квартиры" id="Number" name="Number" style="width:100%;" value="" /></div><div class="k-edit-label">    <label for="Number">Подъезд</label></div><div class="editor-field">    <input class="k-textbox" id="Entrance" name="Entrance" style="width:100%;" value="" /></div><div class="k-edit-label">    <label for="Number">Этаж</label></div><div class="editor-field">    <input class="k-textbox" id="Floor" name="Floor" style="width:100%;" value="" /></div><div class="k-edit-label">    <label for="Number">Площадь</label></div><div class="editor-field">    <input class=\'numeric\' value=\'#=Sqm#\' name=\'Sqm\' /></div><p>    <input data-val="true" data-val-number="The field Площадь must be a number." data-val-required="The Площадь field is required." id="Sqm" name="Sqm" style="width:100%;" type="number" value="" /><script>jQuery(function(){jQuery("';Sqm").kendoNumericTextBox({});});</script>    </p>;$kendoOutput+=;}return $kendoOutput;

My property is of type double

 

now I had to workaround this by using input in clietntemplate

<input data-val="true" data-val-number="The field Площадь must be a number." data-val-required="The Площадь field is required." id="Sqm" name="Sqm" style="width:100%;" type="number" value="" />

and catch OnEdit event of Grid where I can enhance input like

jQuery(function(){jQuery("#Sqm").kendoNumericTextBox({});});

 

But I rather user @Html.Kendo().NumericTextBoxFor for my convinience

 

 

 

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 23 Dec 2016, 11:25 AM
Hi Dima,

Please examine the following article that lists common cases when the error you are seeing is observed.


Give the suggestions there a try and see how they work for you.


Regards,
Viktor Tachev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Dina
Top achievements
Rank 1
answered on 23 Dec 2016, 11:49 AM

Em

"This can happens if the wrapper is declared without ToClientTemplate()."

In my case it is declared with ToClientTemplate() and expect ToClientTemplate() escape all ##  propelly

like this

@Html.Kendo().TextBoxFor(m => m.Entrance).ToClientTemplate()

works perfectly well but this does not

@Html.Kendo().NumericTextBoxFor(m => m.Sqm).ToClientTemplate()
0
Viktor Tachev
Telerik team
answered on 27 Dec 2016, 11:55 AM
Hi Dima,


Please examine the following thread that describes how you can escape the hash symbols when they are present in the value of the column.

In case the behavior persists please send us a small project where the issue is replicated. Thus, we will be able to examine the scenario and look for what is causing the error.

Regards,
Viktor Tachev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Dina
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Dina
Top achievements
Rank 1
Share this question
or