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

Cannot use Kendo NumericTextBox as ClientTemplate for a detail grid column

2 Answers 373 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marius
Top achievements
Rank 1
Marius asked on 27 Jun 2013, 01:09 AM
I have a master-detail grid and I want to use a Kendo NumericTextBox as ClientTemplate for one of the columns in the detail grid:

columns.Bound(x => x.MaximumWindowWeeks).ClientTemplate(this.Html.Kendo().NumericTextBox<int>().Name("Test").ToClientTemplate().ToHtmlString());

When expanding the details for a given row, I get the error below and none of the rows are rendered:

SyntaxError: unterminated string literal
...itle":"Maximum Window Weeks","template":"<input id=\"Test\" name=\"Test\" type=\...

Do I need to somehow "escape" the column client template, since I'm defining it as part of another client template?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 28 Jun 2013, 08:28 AM
Hi Marius,

 
In current scenario I would suggest to include only input element in the ClientTemplate and use the DataBound event of the child Grid to initialize the NumericTextBoxes. Please check the example below:

  • ClientTemplate:
    columns.Bound(od => od.UnitPrice).Width(200).ClientTemplate("<input class='numeric' value='\\#=UnitPrice\\#' name='UnitPrice' />");
  • DataBound event handler:  
    function onDataBound(e) {
        var grid = this;
        grid.tbody.find('.numeric').each(function () {
            //additionally you can initialize the comboBoxes with change event handler
            //in which to save the new value to the underlying model
            $(this).kendoNumericTextBox();
        })
    }
  •    
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Marius
Top achievements
Rank 1
answered on 12 Jul 2013, 01:33 PM
Hi Vladimir,
Thank you for your answer. The solution you suggested worked.
It would be really nice if Razor syntax would be supported in this scenario. Maybe that will be possible in future releases.
Tags
Grid
Asked by
Marius
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Marius
Top achievements
Rank 1
Share this question
or