When to use 'data.' in clientTemplate?

2 posts, 0 answers
  1. Alex
    Alex avatar
    76 posts
    Member since:
    May 2015

    Posted 24 Feb 2017 Link to this post

    I'm quite confused as to when I need to prefix my row data with "data." versus when I don't.

    For instance, the example on the FAQ never mentions that you need to prefix "Enable with "data." (i.e. "data.Enabled") to access the Enabled field. But in my code if I don't do "data.Enabled" I get an undefined error.

    But, if I do something like

    #= fieldName != null  ?  kendo.toString(fieldName)  :  '' #

    I don't have to do data.fieldName. Also, many example I find in the forums sometimes include data. and other times they dont. Is there some place I can look at that tells me when I need to use "data." and when I don't?




  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    2062 posts

    Posted 28 Feb 2017 Link to this post

    Hello Alex,

    In the general case the  syntax: 

    #= fieldName != null  ?  kendo.toString(fieldName)  :  '' #

    and the syntax should be the same 

    #= data.fieldName != null  ?  kendo.toString(data.fieldName)  :  '' #

    Could you please specify what is your case when data is required otherwise you get an undefined? 

    Boyan Dimitrov
    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.
Back to Top