This is a migrated thread and some comments may be shown as answers.

Color Row Based On Datasource

1 Answer 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 2
Joshua asked on 08 May 2015, 03:02 PM

I am trying to color a row based on the results that returned from the datasource.

Is there a good clean way to accomplish this? The result comes back as a Hex value (not shown in the code below) so it can be a simple concatenation if needed in my MVC or Jquery. I just dont know the best way to perform this. Please help. Thanks

 

@(Html.Kendo().Grid<Guardian.ViewModels.ExtendedTicketModel>()
      .Name("mytickets_grid")
      .Columns(columns =>
      {
          columns.Bound(ticket => ticket.RequesterId);
          columns.Bound(ticket => ticket.RequesterName);
          columns.Bound(ticket => ticket.TopicName);
          columns.Bound(ticket => ticket.Created).Format("{0:MM/dd/yyyy hh:mm tt}");
          columns.Bound(ticket => ticket.Id).Title("Actions").ClientTemplate("<button class=\"btn btn-primary\" onclick='location.href=\"/Ticket/Details/#=Id#\"'>Details</button>");
      })
      .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("_MyOpenTickets_Read", "Ticket", new{ username = HttpContext.Current.Items["sAMAccountName"].ToString() }))
      )
      .Sortable()
      .Pageable()
      .Filterable()
      )
 
<style scoped="scoped">
    .k-detail-cell .k-tabstrip .k-content {
        padding: 0.2em;
    }
</style>

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 11 May 2015, 10:59 AM

Hello Joshua,

You could apply the custom styling in the dataBound event of the Grid. The approach is demonstrated in the following example.

Regards,
Dimiter Madjarov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Joshua
Top achievements
Rank 2
Answers by
Dimiter Madjarov
Telerik team
Share this question
or