mleibman / SlickGrid

A lightning fast JavaScript grid/spreadsheet
http://wiki.github.com/mleibman/SlickGrid
MIT License
6.81k stars 1.98k forks source link

Set row background color based on cell value? #932

Closed truvali89 closed 10 years ago

truvali89 commented 10 years ago

I wonder if SlickGrid has this ability, for example, I want every row that has Age value be between 20 - 40, to have blue background color. I have searched everywhere and I couldn't find any example that show that kind of feature. I want to know so that I can move on to search another Javascript widget.

rostg commented 10 years ago

You need to implement getRowMetadata(index) in your data provider. If you are using Slick.DataView data provider then you need to override this function since it returns metadata only for 'group' items.

truvali89 commented 10 years ago

I am new in slickgrid. I could not find any examples. Can you send your code sample ?

truvali89 commented 10 years ago

Example Code : http://stackoverflow.com/questions/19496846/slickgrid-how-to-loop-through-each-row-and-set-color-based-on-the-condition/19599633#19599633 But it is not running. I take error undefined "metadata" functions. Where is the "metadata" functions?

rostg commented 10 years ago

The "metadata" function is right there, just below the first line in the example from your link.

truvali89 commented 10 years ago

dataView.getItemMetadata = function(row) { var item = dataView.getItem(row); if(item.title === "Task 0") { return { cssClasses: 'backRed' }; } }; Through with this code successfully added "backRed" class But not appear background red. Something crushing to "backRed" class. What should I do ? Thanks for help ...

rostg commented 10 years ago

Did you define background-color for 'backRed' class in your .css file?

truvali89 commented 10 years ago

Yes I Did. I solved the problem. Thanks for helps.

rostg commented 10 years ago

Please, close the issue.