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

[Solved] Nested DatePicker

1 Answer 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Corey Goux
Top achievements
Rank 1
Corey Goux asked on 01 Apr 2010, 04:56 PM
I am trying to nest a Telerik DatePicker control inside a Telerik grid and for some reason, I cannot get the calendar popup to work.  I have tried several different ways of doing this, some have generated errors, but below is best result I have seen so far.  I can easily add the DatePicker control outside of the Telerik grid and everything works just fine.  Are nested controls allowed?  Am I missing something?

Thanks,
Corey

Html.Telerik().Grid(Model.MyObject)  
  .Name("MyGrid")  
  .Columns(columns => 
  {  
    columns.Bound(s => s.MyNo).Title("My #").Width(50);  
    columns.Bound(s => s.MyName).Title("My Name");  
    columns.Template(s => 
    {%> 
       <%= Html.Telerik().DatePicker()  
             .Name("MyDatePicker")  
             .ShowButton(true) %> 
    <%}).Title("My Date Time").Width(160);  
    columns.Bound(s => s.MyStatus).Width(50);  
    columns.Bound(s => s.MyQuantity).Title("My Qty").Width(60);  
    columns.Bound(s => s.MyWeight).Title("My Weight").Width(80);  
    columns.Template(s => 
    {  
     %> 
     <%=Html.Hidden("MyHidden", s.MyId)%> 
     <%i++;  
    }).Title("").Width(0);  
  })  
  .Render();  
 

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 02 Apr 2010, 08:05 AM
Hello Corey Goux,

The problem is that the name of the datepicker is always the same. This is not supported - the name of every datepicker should be unique. The same goes with the hidden input. An input with the same id will be created for each grid row. I suggest you use display templates for this case - please check the display and editor templates help topic and the associated example. Also check the provided templates in the Views/Shared/EditorTemplates and Views/Grid/DisplayTemplates folder of the sample application.

Regards,
Atanas Korchev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Corey Goux
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or