In our typescript application we have a kendo grid. In Product.ts I'm defining the columns like this:
const cols = <kendo.ui.GridColumn[]>[
{ field: "Name", title: "Name" },
{ field: "ProductDate", template: "#= kendo.toString(ProductDate, 'dd.MM.yyyy') #" title: "Date" },
{ field: "IsNew", template: "# if (IsNew == true) { 'Yes' } else { 'No } #", title:"Is new" }];
After that, I add them to the grid by using this:
let grid = this.grid.kendoGrid({
dataSource: this.unitDataSource,
pageable: true,
filterable: true,
sortable: true,
columns: cols
}).data("kendoGrid");
Now I have the problem that the date and the boolean fields aren't correctly shown:
Format of ProductDate in grid: 2016-08-23T15:37
IsNew isn't shown at all
Instead of template
I also tried it with format: "{0:dd.MM.yyyy}"
for the date what gave me the same result.
I don't get any error messages in browser console.
What am I doing wrong?
EDIT
dimodi's answer solved my problem with the boolean field. My template now looks like this:
"# if (IsNew == true) { # Yes # } else { # No # } #"
As P. Ommer wrote in his answer, I added the date to the schema. The date is now shown in the correct format with my template but if there is no date specified, "null" is shown instead of nothing. When I change the template to "# if (ProductDate != null) { kendo.toString(ProductDate, 'dd.MM.yyyy') #"
, the product date column stays empty for each row.
How do I treat null columns for the date?