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

[Solved] CellAction and filterable columns in batch edit grid

1 Answer 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Shelley
Top achievements
Rank 1
Shelley asked on 02 Feb 2012, 02:19 AM
I have an editable grid and I have used CellAction to add a green border if the cell is editable.  However I also have filtering enabled for these columns and if the user filters the data the styling added to the cells is removed.  Any ideas how I can retain this styling within the grid for these specific fields?

.CellAction(cell =>        {           
    if (cell.Column.Title == "Tagging Type" ||
        cell.Column.Title == "Comments" ||
        cell.Column.Title == "Delete" )           
    {  
        //Set the background of this cell only                   
        cell.HtmlAttributes["style"] = "border: 1px solid green !important; ";           
    }           
})

1 Answer, 1 is accepted

Sort by
0
Shelley
Top achievements
Rank 1
answered on 03 Feb 2012, 07:16 PM
function Grid_onRowDataBound(e) {
    var grid = $(this).data('tGrid');
    var style = "";
    for (var i = 0; i < grid.columns.length; i++)
    {
        if (grid.columns[i].title == "Tagging Type" ||
            grid.columns[i].title == "Comments" ||
            grid.columns[i].title == "Delete")
        {  
            style = "border: 1px solid green !important; ";
        } else {
            style = "";
        }
        e.row.cells[i].style.cssText = style; 
    }
}
Solved this by creating an event for onRowDataBound and added the following javascript:

Tags
Grid
Asked by
Shelley
Top achievements
Rank 1
Answers by
Shelley
Top achievements
Rank 1
Share this question
or