Cannot use Kendo NumericTextBox as ClientTemplate for a detail grid column

3 posts, 1 answers
  1. Marius
    Marius avatar
    3 posts
    Member since:
    Jan 2013

    Posted 26 Jun 2013 Link to this post

    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. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2204 posts

    Posted 28 Jun 2013 Link to this post

    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!
  3. Marius
    Marius avatar
    3 posts
    Member since:
    Jan 2013

    Posted 12 Jul 2013 Link to this post

    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.
Back to Top