views:

34

answers:

1

Hi.

I have been working with jqGrid and am a bit stumped as to why the following will not operate as expected, the single line of code simply uses the formatter to update a row - if I insert a value into the ID parameter it works fine (see commented line) - and if I use a variable it simply doesnt work.

Am I missing something?

The ID for the row is numeric.

The following is called from colModel using the formatter ->

        //formatter
    typeHighlight = function(cellvalue,options,rowdata){
        if(cellvalue == "Invoice Required" || cellvalue == "Finished"){

            var rowID = options.rowId; //gets the row id        
            setRow(rowID); //sets the row colour

            return cellvalue;
        }else{
            return cellvalue;
        }
    }

    setRow = function(rowID){
$("#list2").jqGrid('setRowData',rowID,false,'rowDone'); //new api
//$("#list2").setRowData(rowID,false,'rowDone');  //old method
//("#list2").setRowData(1323,false,'rowDone'); //note the row id manually inserted

    }

As noted above, when I add the row id in manually - it works, the only thing that fails is when I try to add the row id programatically - it displays in firebug console as a correct value incidentally.

Thank you for any help

Oo

A: 

Look at http://stackoverflow.com/questions/2931732/jqgrid-coloring-an-entire-line-in-grid-based-upon-a-cells-value/2936673#2936673. If it will not solve your problem, then post more information. For example, the definition of the rowDone CSS class, definition of the colModel and so on.

If you include in your question enough information to reproducing of your problem, the problem could be quickly solved.

Oleg
Thanks Oleg, I based my solution upon that.What appears to happen is that the setRowData is applied after the load of the grid, this means that the variable is out of scope (at least that how I see it)I was able to circumnavigate the issue by using the formatter to send a value to a global array and then iterating across the array with calls to setRowData which worked perfectly.The only issue would appear to be that the scope of a variable was incorrect when using setRowData in direct conjunction with the custom formatter.
Owen Lees