We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

Change class of parent row

Answered
Marcos Martins asked on December 22, 2021

Hi, 
I have have three rows in my slice in Compact form:

{
"uniqueName": "DIA"
},
{
"uniqueName": "DIA_SEMANA"
},
{
"uniqueName": "TIPO_DIA"
},

Let's say when TIPO_DIA has the value of "Sab" i need to change the color of my parent row.
When i try to costumize in customizeCell, i don't have no reference to the parent row so i can't change the css.
Is there a way to do this?
Thanks in advance,

Attachments:
color_row.jpg

3 answers

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster December 24, 2021

Hi Marcos,
 
Thank you for raising your support ticket.
 
We've prepared a sample demonstrating how to implement something similar with customizeCell(): https://jsfiddle.net/flexmonster/nwz6bmr4/.
 
Here's how it works:
 

  1. Inside the customizeCell() handler function, all "parent" rows are detected and their cells are assigned the .fm-expandable-N class, which will be used later.
  2. Inside the same function, the lower hierarchy member cells are read – if any of them contains the required member ("Germany" in the sample), the corresponding "parent" row should be painted. Therefore, we push the last "parent" row index to the global rowsArrToPaint array variable.
  3. Finally, after the customizeCell() handler execution is finished, the aftergriddraw event is triggered. We assign the addExtraStyles() handler for this event – the function creates a new <style > tag, fills it with styles to paint the necessary rows, and appends the tag to the document head.

 
As a result, only the "parent" nodes with the "Germany" child members are painted.
 
Please let us know if this helps.
 
Best regards,
Mykhailo

Public
Marcos Martins December 24, 2021

Hi,
From what I saw in your example, I think this is really what was needed, I will forward it to the department that is implementing the functionality that uses the table in which this was necessary, if i receive any feedback with any questions, I will contact you .
Thank you very much,

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster December 24, 2021

Marcos,
 
Thank you for your response, good to hear the suggested solution seems valid to you!
 
As always, feel free to reach out in case there is anything else we can help you with.
 
Regards,
Mykhailo

Please login or Register to Submit Answer