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

DatePicker not displaying when using dynamic code

1 Answer 397 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 09 May 2017, 12:54 PM

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

e.g.

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

 

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 11 May 2017, 09:19 AM
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.


Regards,
Tsvetina
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
Date/Time Pickers
Asked by
Paul
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or