General Category > Help for ParamQuery Pro

Conditional Cell Formatting

(1/5) > >>

mikep:
Hi, in the example below, I would like the cells to be formatted on initial load and when a profit or revenue value changes. I used your example from the website, but it's not working for me.

https://jsfiddle.net/k5m8aL92/3/

paramvir:
Please use the recent version of pqgrid.

https://jsfiddle.net/hfs1pm78/

mikep:
Thank you. How could I also apply the logic make the cell read-only in addition to coloring it red?

paramvir:

--- Code: ---render: function(ui) {
    var rd = ui.rowData;
    var edit = rd.pq_cellprop = rd.pq_cellprop || {}
    edit[ui.dataIndx] = {edit: true};
  if (rd.profits < rd.revenues) {
    return {
      style: {
        'background': 'blue'
      }
    };
  } else if (rd.profits > rd.revenues) {   
    return {
      style: {
        'background': 'green'
      }
    };
  } else {
    edit[ui.dataIndx] = {edit: false};
    return {
      style: {
        'background': 'red'
      }
    };
  }
}

--- End code ---

https://jsfiddle.net/w504q2fo/

mikep:
Your example works, but when I transferred to my grid, it doesn't work.
I want to make a cell read only based on the value of another cell in the row. Can you correct/simplify below?
The breakpoint is getting hit at rd.CostCenter == "1296" but the cell remains editable.

                var colM = [
                    { title: "Reserve", width: 70, includeInSum: true, summary: { type: "sum" }, dataIndx: "STE_Hours_Reserved", datatype: "float", align: "right",
                        render: function (ui) {
                            var rd = ui.rowData;
                            var zz = rd.pq_cellprop = rd.pq_cellprop || {}
                            zz[ui.dataIndx] = {edit: true};

                            if (rd.CostCenter == "1296") {
                                zz[ui.dataIndx] = { edit: false };
                            }
                        }
                 ]
                    }
                ];

Navigation

[0] Message Index

[#] Next page

Go to full version