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

Conditional Formatting / Column locking

1 Answer 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 12 Nov 2015, 10:36 PM

I'm color coding some cells in a grid with code similar to the snippet below.

1. Is this the most efficient way to perform cell level conditional formatting? I have some pretty large datasets, and it doesn't seem like a great solution.

2. Locking columns breaks this logic by changing the cell's array position. Is there a way around this without parsing through the entire grid when a column is locked?

 

var grid = $('#myGrid').data('kendoGrid');
        var rows = grid.tbody.find(" > tr");
        var rowCount = grid.tbody.find(" > tr").length;
        if (rowCount > 0) {
            for (var x = 0; x < rowCount; x++) {
                var dataItem = grid.dataItem(rows[x]);
                var row = rows[x];
                if (dataItem.foo === 'bar') {
                    row.cells[0].style.backgroundColor = "#e0e0eb";
                }
}

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 16 Nov 2015, 09:28 AM

Hello Marc,

There is no built in way to add conditional styling to the cell itself, depending on the dataSource data, so the current approach is the correct way to achieve the task.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Marc
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or