Author Topic: Conditional Cell Formatting  (Read 6837 times)

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 132
    • View Profile
Re: Conditional Cell Formatting
« Reply #15 on: May 19, 2021, 07:45:32 pm »
Disregard my last request. At the moment I don't need to apply this grouping granularity. Thanks again.

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 132
    • View Profile
Re: Conditional Cell Formatting
« Reply #16 on: July 13, 2021, 06:07:30 pm »
For grouped rows: I would like to change the background of the grouping row to red if two particular columns are not equal AND if the group row is grouped by a particular column.
In my jsfiddle, if month1 <> month 2 AND is grouped by Rank, then color red.

https://jsfiddle.net/z3w2Lthc/

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: Conditional Cell Formatting
« Reply #17 on: July 14, 2021, 08:54:11 am »
Code: [Select]
rowInit: function(ui) {
  var rd = ui.rowData;
  if (rd.pq_gtitle) {
    if ((rd.month1 != rd.month2) && (this.option('groupModel.dataIndx').indexOf('rank') >= 0))
      return {
        style: 'background:red;'
      }
    else
      return {
        style: 'background:#ff9812;'
      }
  }
},

https://jsfiddle.net/nmyj7ezh/2/

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 132
    • View Profile
Re: Conditional Cell Formatting
« Reply #18 on: July 27, 2021, 05:18:03 pm »
Thank you. What is the syntax If I only want to color 1 column (month1) red in the grouping row? I tried a render function for the column but could figure out the group logic.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: Conditional Cell Formatting
« Reply #19 on: July 27, 2021, 07:09:28 pm »
Same syntax.

move same code to column.render callback:

https://jsfiddle.net/4sfkjn90/

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 132
    • View Profile
Re: Conditional Cell Formatting
« Reply #20 on: July 29, 2021, 12:31:36 am »
Thanks! Follow on question. Now that I've applied a cell color, the red tracking indicator no longer appears after the cell is edited. The grid still remembers the edited rows, but the indicator doesn't display. Adding this callback makes the "dirty" indicator not appear. Any ideas?

colAP.render = function (ui) {
  return { style: 'background:pink' };
}

Here's an example that mimics my layout, but in this example the indicator DOES appear. Hopefully you may have an idea.
http://jsfiddle.net/vydnwLoa/6/

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: Conditional Cell Formatting
« Reply #21 on: July 29, 2021, 03:11:47 pm »
Please use 'background-color' instead of background.

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 132
    • View Profile
Re: Conditional Cell Formatting
« Reply #22 on: August 10, 2021, 12:58:15 am »
Thank you. How can I color column headers dynamically? In the example below, I'd like the column headers (both rows) colored the same as the cells.

https://jsfiddle.net/mc95f4d0/3/

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 132
    • View Profile
Re: Conditional Cell Formatting
« Reply #23 on: August 11, 2021, 07:32:16 pm »
Hello, will you be able to address this in the next day or 2?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: Conditional Cell Formatting
« Reply #24 on: August 12, 2021, 11:09:54 am »
Sorry, header cells can't be dynamically styled.