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

.RowAction .CellAction HtmlAttributes are lost when user pages or sorts grid

2 Answers 383 Views
Grid
This is a migrated thread and some comments may be shown as answers.
D
Top achievements
Rank 1
D asked on 14 Mar 2011, 08:52 PM
If I set the color of a row for the grid it works great until the user pages or sorts the grid then I loose the color setting for the row.  I have tried using the the CellAction and it also looses the HtmlAttributes. Is it because it is an Ajax bound grid?  Is there a work around?

        .Grid(Model)
        .Name("DetailGrid")
.RowAction(row =>
{
if (row.DataItem.Status == "X")
{
row.HtmlAttributes["style"] = "background:#FFCCCC;";
}
})

                code for .columns goes here........
        .DataBinding(x => x.Ajax().Select("AjaxDetails""Policy"new { OID = ViewData["OID"] }))

2 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 17 Mar 2011, 02:07 PM
Hi,

Could you please let me know if the RadGrid cell styling works as expected if the Ajax is disabled on the page? Also please try setting the EnableAjaxSkinRendering="true" for the RadGrid control and verify if this makes any difference.


Kind regards,
Maria Ilieva
the Telerik team
0
D
Top achievements
Rank 1
answered on 17 Mar 2011, 06:13 PM
I should have specified that this is a ASP.Net MCV Telerik grid and not a RadGrid. 

I found a solution. In addition to the .RowAction for the grid, I had to add the .ClientEvents to handle the client side Ajax calls that sort and refresh the grid in order to repaint the row color correctly.

<% Html.Telerik()
.Grid(Model)
.Name("DetailGrid")
.RowAction(row =>
{
if (row.DataItem.Status == "X")
{
row.HtmlAttributes["class"] = "deleted-row";
}
})
.ClientEvents(events => events.OnRowDataBound(() =>
{
    %>
function DetailGrid_onRowDataBound(e) {
if (e.dataItem.Status == 'X') {
$(e.row).addClass('deleted-row');
}
}
<%
}))
Tags
Grid
Asked by
D
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
D
Top achievements
Rank 1
Share this question
or