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

Client Template in grid column

4 Answers 252 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lars
Top achievements
Rank 1
Lars asked on 28 Aug 2015, 11:36 AM

Hi Everybody,

 I have a problem using the grid in asp.net mvc and Telerik for asp.net mvc.

 The Client template works fine when entering information and fine display a DateTimePicker.

  But when I leave the field is become empty instead of the Value choosed in the DateTimePicker.
    Do you have any suggestions?

<P>@(Html.Kendo().Grid<​Object.Clubs>().BindTo(Model.​Clubs).Name("Clubs")<BR>.ToolBar(configurator
=><BR>                        {<BR>                           
configurator<BR><BR>.Create();<BR>                        })<BR><BR>.Editable(e
=>
e.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))<BR>.Events(e
=> e.Edit("onEditItem")).Events(e =>
e.Save("onSaveItem"))<BR>.Columns(columns =><BR>                        {<BR>
                           columns<BR><BR>.Bound(m =>
m.​ClubName).EditorTemplateName("​RelatedClubs").ClientTemplate("#= ​ClubName#"
+<BR>"<input type='hidden' name='Clubs[#= indexClub(data)#].​ClubName'
value='#= ​ClubName#' />"<BR>                            );<BR>              
             columns</P>
<P><BR>.Bound(m => m.EndDate).Width(150).Encoded(true).ClientTemplate("#
if(EndDate != null){ kendo.toString(kendo.parseDate(EndDate,'dd/MM/yyyy'), '" +
"dd-MM-yyyy" + "') } else { kendo.toString('') } #" +<BR>"<input
type='hidden' name='Clubs[#= index​Club(data) #].EndDate' value='#=
ConvertDate(​EndDate) #' />").Format("{0: dd-MM-yyyy}");<BR>                 
          columns<BR><BR>.Command(m => m.Destroy()).Width(100);<BR>          
             })<BR><BR>.DataSource(dataSource => dataSource.Ajax()<BR>.Read(r
=> r.Action("​ClubsRead", "Model"))<BR>.Model(model =><BR>                
       {<BR>                            model<BR><BR>.Id(p => p.Id);<BR>     
                  })<BR>                        )<BR><BR>)</P>
 

Best Regards

  Lars

4 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 01 Sep 2015, 08:23 AM
Hi,

I am not sure I understand what the issue with this scenario is. I tried replicating it here, but everything seems to work as expected - changing the value of the field through the DatePicker changes the input's value in the template as well. Would you please elaborate what the expected and the actual behavior is? Also, feel free to modify the Dojo so the issue is observed and share the new URL with us.

Regards,
Alexander Popov
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
0
Lars
Top achievements
Rank 1
answered on 01 Sep 2015, 12:25 PM

Hi Alexander,

 Have you tried in a ASP.NET MVC Project, like to one I have problems with?

I want exactly this behavior in the Grid as you show in the DOJO related to Kendo UI.
 We are using version: 2015.1.408

 

Best Regards

  Lars

0
Lars
Top achievements
Rank 1
answered on 01 Sep 2015, 12:27 PM

Hi Alexander,

 I also want to have a condition inside my Client template, so if the value is null to grid cell should shows as empty and when there is a value if should show this value.

 

/Lars

0
Accepted
Alexander Popov
Telerik team
answered on 03 Sep 2015, 09:58 AM
Hello Lars,

I tried reproducing this in ASP.NET MVC environment, however I still got the expected results (see screencast). Would you please share all related code, or ideally - a runnable sample project, so we can proceed with the investigation?
Regarding your latest question - JavaScript expressions are allowed inside the Kendo UI templates, so you can use if-else statements to control what is rendered.

Regards,
Alexander Popov
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
Lars
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Lars
Top achievements
Rank 1
Share this question
or