Client Template in grid column

5 posts, 2 answers
  1. Lars
    Lars  avatar
    11 posts
    Member since:
    Jul 2015

    Posted 28 Aug 2015 Link to this post

    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

  2. Answer
    Alexander Popov
    Admin
    Alexander Popov avatar
    1442 posts

    Posted 01 Sep 2015 Link to this post

    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
  3. Lars
    Lars  avatar
    11 posts
    Member since:
    Jul 2015

    Posted 01 Sep 2015 Link to this post

    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

  4. Lars
    Lars  avatar
    11 posts
    Member since:
    Jul 2015

    Posted 01 Sep 2015 in reply to Lars Link to this post

    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

  5. Answer
    Alexander Popov
    Admin
    Alexander Popov avatar
    1442 posts

    Posted 03 Sep 2015 Link to this post

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