Get Free Trial

flat grid – get data property

Dejan asked 7 days ago

Hi, I am trying to change background of one column data dynamically based on values from JSON (like BG color). 
I experimented with customizeCellFunction and closest I got is defining BG color field as ID and refer to it like this: 
function customizeCellFunction(cell, data) {
if (!(data.hierarchy && data.hierarchy.uniqueName == “koren”)) return;
let newText =
`<p style=’background-color:${data.recordId}’>${data.escapedLabel}</p>`;
if (data.type == “header” && data.member) {
let parts = cell.text.split(data.escapedLabel);
if (parts.length == 2) {
newText = parts[0] + newText + parts[1];
cell.text = newText;
} else if (data.type == “value” && (data.member || data.isDrillThrough)) {[‘z-index’] = 1;
cell.text = newText;
And it works. 
Then I wanted to implement some URLs and aditional other BG fields but I got stuck since only 1 ID is supported.
I then saw option to use ‘property’ in JSON dataset but can’t figure out how to refer to certain property in customizeCellFunction. 
I searched through examples and find for instance how to create ‘alerts’ etc. from ‘properties’ but struggle how to use them in customizeCellFunction. 
Please note I need this only for flat view.

1 answer

Maksym Diachenko Maksym Diachenko Flexmonster 5 days ago

Hello, Dejan!

Thank you for your question.

While using the flat mode, the property fields are stored inside the object inside the CellDataObject. Please note that you should also specify the certain string hierarchy. You will be able to access this property only from cells of this hierarchy:

"bgColor": {
type: "property",
    hierarchy: "koren"

You are welcome to check the JSFiddle example using multiple properties for customizing cells: 

Looking forward to hearing your feedback.

Best Regards,

Please login or Register to Submit Answer