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

Color grid cells without row template

0 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
underscore
Top achievements
Rank 1
underscore asked on 10 Jan 2012, 09:39 AM
I found the row templates difficult to implement in large grids, in particular with alternate shading. So I came up with some jquery solution. First of all, we need an own style

<style>
.highlight { background:yellow; }
</style>

Then we need a function that is executed inside the document.ready block that will highlight all fields with content "-1".

$(".k-grid-color").bind('click', function () {
$('td').each(function(){
if ($(this).text().indexOf('-1') > -1) {
$(this).toggleClass("highlight");
        }
});
});

And we need a nice button, to switch on the light

{ text: "Color", className: "k-grid-color"}

Maybe that is of use also for some more coders.

No answers yet. Maybe you can help?

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