rowCallback or rowClassFn Function In kendo Grid

1 Answer 3157 Views
General Discussions
Govardhan
Top achievements
Rank 1
Govardhan asked on 02 May 2018, 12:02 PM

Hi I  am working on the kendo Grid where  the color of the row should change based on the Category name, Which I will hard code and switch between the values in rowCallback function.

However as per the example   https://www.telerik.com/kendo-angular-ui/components/grid/api/GridComponent/#toc-rowclass There is only even and odd, So can I do a switch functionality using the rowCallback function.  or do I need to use the "Styling Cells on the Fly" functionality https://www.telerik.com/kendo-angular-ui/components/grid/styling/#toc-styling-cells-on-the-fly where I need to mention the style for each specific cell in  entire row.

 

 

Regards

K Govardhan.

1 Answer, 1 is accepted

Sort by
1
Dimiter Madjarov
Telerik team
answered on 02 May 2018, 12:51 PM
Hi Govardhan,


The RowClassArgs argument, which is received by the rowClass function contains two properties - index (which is used in the even/odd example) and dataItem (which holds the whole item for the current row).

https://www.telerik.com/kendo-angular-ui/components/grid/api/RowClassArgs/

https://www.telerik.com/kendo-angular-ui/components/grid/api/GridComponent/#toc-rowclass

I assume that using the dataItem property and retrieving the Category value is what you are looking for. Let me know if I could assist further.

Regards,
Dimiter Madjarov
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.
Bob
Top achievements
Rank 1
commented on 29 Oct 2018, 09:57 PM

Dimiter,

In the rowCallback function, "this" refers to the TableBodyComponent.

How can I reach any variables/methods at the parent component level?

Thanks in advance for your help.

Bob

Dimiter Madjarov
Telerik team
commented on 31 Oct 2018, 07:17 AM

Hi Bob,


This could be achieved by switching the callback implementation to an arrow function. Here is an example of this:

https://stackblitz.com/edit/angular-yh8zyr?file=app/app.component.ts

Regards,
Dimiter Madjarov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Bob
Top achievements
Rank 1
commented on 02 Nov 2018, 07:30 PM

Hi Dimiter,

This works perfectly! Thanks for the help!

Bob

Mark
Top achievements
Rank 1
Veteran
Iron
commented on 25 Aug 2020, 05:04 PM

Can rowCallback be evaluated dynamically in case data gets changed so does the row style condition?
Martin
Telerik team
commented on 27 Aug 2020, 09:51 AM

Hi Mark,

In order to style the Grid rows conditionally please check the following section from our documentation:

https://www.telerik.com/kendo-angular-ui/components/grid/styling/#toc-highlighting-specific-row-cells

Regards,
Martin
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
General Discussions
Asked by
Govardhan
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or