DatePicker not displaying when using dynamic code

2 posts, 0 answers
  1. Paul
    Paul avatar
    1 posts
    Member since:
    May 2017

    Posted 09 May 2017 Link to this post

    I am trying to use the Kendo DatePicker from code generated and rendered into the view, I can make it work when part of the cshtml


    In cshtml:

    @(Html.Kendo().DatePicker().Enable(!Model.ReadOnly).Name("DatePick").Value("12/25/2017").HtmlAttributes(new { style="width: 10% ", title="datepicker" }))

    works fine.

    when rendering from

                                result.Append("@(Html.Kendo().DatePicker().Enable(" + !ReadOnly + ").Name(\"a" + PrimKey + "\").Value(\"" + theDate + "\").HtmlAttributes(new { style=\"width: 10%\", title=\"datepicker\" }))\r\n");

    I just get the text and no control.

    I am using the code generation for all my controls on the page as it is dynamic and not a preset layout


  2. Tsvetina
    Tsvetina avatar
    2189 posts

    Posted 11 May 2017 Link to this post

    Hi Paul,

    The server-side wrappers are used with declarative definition of the widgets only. If you want to return HTML and initialize the widgets dynamically, you should rather do what the server-side wrappers are internally doing - outputting the widget HTML wrapper element and initialization script.
    Take a look at this help article:
    Overview of Server-Side Wrappers

    The server-side wrappers execute on the server and output HTML and JavaScript on the client.

    Your code should be returning the same HTML/JS output as the server wrappers, for example:
    <input id="age" type="text" value="10"/><script>jQuery(function(){jQuery("#age").kendoNumericTextBox({spinners: false});});

    Give this a try and let me know if you have additional questions.

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