ryansuitposungkono / openjs-grid

Automatically exported from code.google.com/p/openjs-grid
0 stars 0 forks source link

how to give color to row and cell depend upon the value or condition? #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
want to display rows and columns depend upon the condition we provide.

What version of the product are you using? On what operating system?
windows 7, openjs 1.8

Please provide any additional information below.

Original issue reported on code.google.com by saravana...@gmail.com on 13 Oct 2011 at 10:59

GoogleCodeExporter commented 9 years ago
This is how I've done it
This grid will check a date in one of the columns called EndDate and check it 
against the current time.  If the end date is less than the current time, it 
adds a class to the row, which is defined in css to make the row red.

Basically your using loadComplete and looping through the Tds of the column you 
want, checking values, and applying classes to the rows.

$(".all").loadGrid({
    inlineEditing:true,
    stickyRows:false,
    width:1100,
    adding:true,
    deleting:true,
    loadComplete : function() {
        var $grid = $(this);
        $grid.getCol("EndDate").getTdsFromTh().each(function() {
            var dateString = $(this).find(":input").val();
            var end = new Date(dateString);
            var now = new Date();
            // expired
            if(end < now) {
                $(this).parents("tr").addClass("expired");
            }           
        });
    }
});

Original comment by Seancla...@gmail.com on 17 Oct 2011 at 12:04

GoogleCodeExporter commented 9 years ago
Thank u sir,
Wil u able to show this wit an example?

Original comment by saravana...@gmail.com on 20 Oct 2011 at 9:00

GoogleCodeExporter commented 9 years ago
I made a video on this
http://www.youtube.com/watch?v=Ey2z0HGskkg

Original comment by Seancla...@gmail.com on 16 Nov 2011 at 5:34