Anaya Upadhyay
Anaya Upadhyay

Reputation: 45

Conditional row formatting in kendo-ui grid

I am using Kendo Grid for displaying.

@(Html.Kendo().Grid<ReportModel>()
  .Name("myReport")
  .Columns(cols =>
    {
       columns.Bound(c => c.sNo).Title("S.No.");
       columns.Bound(c => c.particulars).Title("Particulars");
    }
  )
  .DataSource(ds => ds
     .Ajax()
     .PageSize(20)
     .Read(read => read.Action("myReportList","Reporting")
  )
  .Resizable(resize => resize.Columns(true))
)

I want the formatting of the row to change to bold if and only if the cell in the SNo column is an alphabet otherwise the formatting must be normal.

Help me achieve this.

Upvotes: 2

Views: 4017

Answers (2)

AMAN KUMAR
AMAN KUMAR

Reputation: 1

You can write it like this:

columns.Bound(c => c.sNo)
    .ClientTemplate("<strong> #=DateOfService#</strong>")
    .Title("S.No.")

Upvotes: 0

dimodi
dimodi

Reputation: 4139

There are a few different ways to achieve that:

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

  • Use a row template. This approach is suitable if you do not intend to apply hierarchy, grouping, editing, and frozen columns to the Grid.
  • Use a databound handler and iterate the table rows. This approach is suitable if you intend to customize all rows of the Grid.
  • Use a databound handler and iterate the data items. This approach is suitable if you intend to customize only part of the Grid rows.

Upvotes: 1

Related Questions