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

When to use 'data.' in clientTemplate?

1 Answer 232 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 24 Feb 2017, 06:50 PM

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?

 

 

 

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 28 Feb 2017, 03:25 PM

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? 

Regards,
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.
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or