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

Kendo controls inside Kendo Template for GridEdit

2 Answers 587 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephan
Top achievements
Rank 1
Stephan asked on 11 Dec 2015, 06:37 AM

Hi,

 Am using Javascript for rendering a Kendo Grid.  In Grid Edit pop up i have a script Template which is an MVC Kendo Template below,

<script id="popup-editor" type="text/x-kendo-template">                 

<div>

@(Html.Kendo().DatePickerFor(m => m.USReleaseDate).HtmlAttributes(new { @class = "form-control", placeholder = "US Release Date" }).Deferred())                </div>

</script>

 Following is my Kendo Editor pop up template code in javascript

template: kendo.template($("#popup-editor").html())

which is perfectly rendering values as expected.

 

However the problem is, the controls inside the pop up is a plain Html control (<input>) instead of kendo date picker. As i read in the forum, i tried to initialize it below the template like this

<script>     

$(function () {         

var usReleaseDate = $("#USReleaseDate");        

 if (usReleaseDate) {             

$("#USReleaseDate").kendoDatePicker( {    

 "format": "MM/dd/yyyy",    

 "min": new Date(1900, 0, 1, 0, 0, 0, 0),     

"max": new Date(2099, 11, 31, 0, 0, 0, 0) });        

 }             

});

but of no use.  How can i render kendo controls within a popup editor?

2 Answers, 1 is accepted

Sort by
0
Stephan
Top achievements
Rank 1
answered on 11 Dec 2015, 07:00 AM
I need it especially for Razor syntax, because when i use data-role attribute in the Template (using Html 5) the control is rendering, but it would be great if i get the same in razor syntax where model binding will occur by default
0
Rosen
Telerik team
answered on 14 Dec 2015, 03:29 PM

Hello Stephan,

I suspect that the widget is not initialized as it is set for deferred initialization. This will result in the need to manually output the initialization scripts, which the not seems to be not done in the template. Instead you should try to substitute the Deferred for ToClientTemplate and see if this makes any difference.

Similar to the following:

@(Html.Kendo().DatePickerFor(m => m.USReleaseDate).HtmlAttributes(new { @class = "form-control", placeholder = "US Release Date" }).ToClientTemplate())

Regards,
Rosen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Stephan
Top achievements
Rank 1
Answers by
Stephan
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or