jQuery UI Widgets Forums Grid Change ROW (Not Column) Background Color

Tagged: , , ,

This topic contains 1 reply, has 2 voices, and was last updated by  Martin 5 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • denkom67
    Participant

    I’m a designer with somewhat modest / limited JavaScript skills who is evaluating JQWidgets as a tool for prototyping design ideas. I’m mainly interested in using the grid control to bind CSV data. I’m evaluating both JQWidgets and Kendo UI. Yesterday I put together a prototype that sets the background color of grid rows based on the value of one of a Status column. Based on some suggestions I found in this forum, I leveraged the ‘cellclassname’ property to define a function that adds one of three classes to each cell in a row based on the Status column value. That works great, but breaks when I apply a group to the grid.

    This is the function code I was using for setting the background color:

    function cellclass(row, columnfield, value){
    var rowid = $(‘#jqxgrid’).jqxGrid(‘getrowid’, row);
    var data = $(‘#jqxgrid’).jqxGrid(‘getrowdatabyid’, rowid);
    if (data.Status == ‘Complete’){
    return ‘complete’;
    } else if (data.Status == ‘In Progress’){
    return ‘in-progress’;
    } else {
    return ‘scheduled’;
    }
    }

    Is there an easy way to apply a background color to rows based on Status, that will also work with grouping? I’ve been looking for a solution for about four hours; I found a working example in Kendo Ui in less than a half hour.


    Martin
    Participant

    Hello denkom67,

    You are getting an error because when you group the grid by some column, the cellclass function is executed with row = -1.
    You can easily fix this by adding the following check at the beginning of the function: if (row === -1) return;.

    I have created an Example for you.
    I hope that this would be useful.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.