1

I'm trying to use template to customize the columns of the grid, and to format the data that will be displayed inside columns. I want to setup this parameter inside my code together with rest of the column parameters, for example...

public gridColumns:any[]=[{

    field:"ProductName",
    title:"ProductName",
    template:'<img src="test.png"/>'
}]; 

However, I noticed that in Kendo UI Angular TypeScript documentation there is no template parameter like it was before the case with AngularJS.

[{
  "Field": "CreateDate",
  "Title": "Creation Date",
  "Width": 75,
  "Template": "#= (data.CreateDate == null) ? ' ' : kendo.toString(kendo.parseDate(data.CreateDate, 'yyyy-MM-dd'), 'dd.MM.yyyy') #"
}]

I guess the main question is: can this be done ? If so, what am I doing wrong.

jovana
  • 11
  • 2
  • 1
    yes it can be done, please check their docs https://www.telerik.com/kendo-angular-ui/components/grid/columns/templates/, they are using ng-template – himawan_r Oct 22 '18 at 03:54

1 Answers1

2

You can use ng template inside the kendo column to achieve this

<kendo-grid [data]="gridData">
        <kendo-grid-column>
            <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
                <span
                    class="column-class">
                        {{dataItem.Data}}
                </span>
            </ng-template>
        </kendo-grid-column>
  </kendo-grid>
Stefan Joseph
  • 545
  • 2
  • 10