A function called in grid cell template always triggering for all data in grid when click or mouseover or etc.

1 Answer 515 Views
Grid
Mehmet Ali
Top achievements
Rank 1
Mehmet Ali asked on 05 May 2021, 08:23 AM

Hello all,

I am using kendo grid. When call a function in cell template, this function is constantly triggering for all data in the grid. It causes a problem when I want to load a lot of data in the grid.

How can i solve this ?

Thanks.

<kendo-grid-column>
<ng-template kendoGridCellTemplate let-dataItem>
{{GetExpenditure(dataItem)}}
</ng-template>
</kendo-grid-column>

 

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 10 May 2021, 06:53 AM

Hi Mehmet,

Invoking functions in Angular template expressions should be avoided. The reason for this is that Angular is not aware when should the function be executed, thus it is invoked on every single change detection cycle, which leads to bad performance. 

The general recommendation is to replace the function call with a simple property binding. This way the logic which changes the property value will be moved outside of the template and invoked only when needed.

Further information about the topic is available in the following article:

https://medium.com/showpad-engineering/why-you-should-never-use-function-calls-in-angular-template-expressions-e1a50f9c0496

Let me know if this information helps.

Regards,
Dimiter Madjarov
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Mehmet Ali
Top achievements
Rank 1
commented on 17 May 2021, 02:54 PM

Thanks Dimiter, this helped me
Tags
Grid
Asked by
Mehmet Ali
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or