Custom class to row based on dataItem

2 posts, 1 answers
  1. Matjaž
    Matjaž avatar
    80 posts
    Member since:
    Jul 2015

    Posted 12 Oct Link to this post

    How can I add custom class to row based on dataItem?

    I think I could use rowTemplate, but that would ignore columns.template which is not OK. I also don't want to change rowTemplate just add some custom classes.

  2. Answer
    Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    347 posts

    Posted 12 Oct Link to this post

    Hello Matjaž,

    You can handle the dataBound event, obtain all rendered items (rows) via the items() method, loop through them and use the dataItem() method to get the corresponding data item, then conditionally add custom class(es) to the TR, based on some property of the data item:

    http://dojo.telerik.com/iLaNUV

    The following how-to article from our documentation shows alternative approaches as well:

    http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Layout/style-rows-cells-based-on-data-item-values

    I hope this helps.

    Regards,
    Dimiter Topalov
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
  3. Kendo UI is VS 2017 Ready
Back to Top