This is a migrated thread and some comments may be shown as answers.
Standard Boolean column using ClientTemplate causes exception
4 Answers 60 Views
This is a migrated thread and some comments may be shown as answers.
Reid
Top achievements
Rank 2
Reid asked on 06 May 2018, 12:47 PM

I am familiar with having a client template for a Boolean column to display "Yes" or "No" for true or false.  I have many templates that use the syntax below with no problems yet this grid on one template will show no data at all if I display that column.  If I comment it out the data shows fine.

 

columns.Bound(a => a.Mosfet.isESD).ClientTemplate("#= isESD ? 'Yes' : 'No' #").Width(80).Title("ESD").Width(100);

 

I can observe the 5 records that are returned in the grid's Read method in the debugger and see that the non null able column has valid values

 

Any suggestions?

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 09 May 2018, 06:25 AM
Hello, Reid,

Thank you for the details.

Indeed, the syntax of the template is valid, as if I place it in some of our demos it is working with no issues.

I noticed that the field is a nested one. This could be the reason as the value "isESD" may not be available like this.

I can suggest using the ClientTemplate as a JS function passing the "isESD" as this will allow determining the actual value that is passed on the template:

https://stackoverflow.com/questions/19819127/how-to-call-javascript-method-from-clienttemplate-in-kendo-grid

If the issue still occurs, please provide an example, as the issue could be caused by a factor which we are overlooking at this moment.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Reid
Top achievements
Rank 2
answered on 10 May 2018, 12:07 PM

Hello Stefan,

I tried about everything this morning to get this working.  It still does not work.  If I employ the JS function you declare it does not get called and the exception is still thrown, or at least the data does not display in the grid.

I believe the problem has to do with the nested objects.  The data type in the grid is a composite object with two nested objects.  Any columns other than Boolean in those objects display just fine. 

The typical client template syntax at the model's root level has no issues ...

columns.Bound(a => a.Active).ClientTemplate("#= Active ? 'Yes' : 'No' #").Width(120);

 

Can you provide a little demo with nested objects containing Boolean values in the model sent to the grid?

Thanks

0
Accepted
Stefan
Telerik team
answered on 11 May 2018, 07:09 AM
Hello, Reid,

I made an example of the nested object and the same template which is working as expected.

I have attached it for reference.

If the issue still occurs, please modify the provided example or send a new one reproducing it, so we will be able to locate the specific issue.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Reid
Top achievements
Rank 2
answered on 11 May 2018, 11:32 AM

Hello Stefan,

Thank you for that demo.  It works now.  The problem was in the syntax of the client template declaration.  I was not qualifying the nested object's field with the nested object itself.

Before:

columns.Bound(a => a.Mosfet.IsEOL).ClientTemplate("#= IsEOL ? 'Yes' : 'No' #").Width(100)

 

After:

columns.Bound(a => a.Mosfet.IsEOL).ClientTemplate("#= Mosfet.IsEOL ? 'Yes' : 'No' #").Width(100)

 

Thank you for your help.

Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Reid
Top achievements
Rank 2
Share this question
or