Handling null values in Kendo Grid Column Templates

1 Answer 3387 Views
Templates
Nag
Top achievements
Rank 1
Nag asked on 07 Jun 2016, 09:07 PM

I have a kendo grid in which one column can have null values. But I don't see the grid populating when there are null values. My code is here:

$(document).ready(function() {

$("#grid").kendoGrid({

dataSource: gridData,

columns: [

{ field: "name", title: "Name"},

{ field: "result",

title: "Result",

template: "# if (result == null) { #" +

"<span data-content=' '></span> } #" +

"# } else { #" +

"<span data-content=\"#: result#\"> </span>"}]})

;});
I don't get the grid shown when the "result" is null. However, I can get the grid when the value is not null. Not sure on how to handle the null values in templates.

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 09 Jun 2016, 08:14 AM

Hello Nag,

There is a curly bracket on the second row of the template that is not needed and breaks the syntax. Here is the updated version.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Templates
Asked by
Nag
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or