Color Row Based On Datasource

2 posts, 1 answers
  1. Joshua
    Joshua avatar
    10 posts
    Member since:
    Mar 2015

    Posted 08 May 2015 Link to this post

    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>

  2. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2299 posts

    Posted 11 May 2015 Link to this post

    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.

     
Back to Top