Pricing changes are coming in January. Contact our Sales team to secure the current price for your desired license.

How to differentiate between expanded second row and first original one in customizeCell

Answered
Nikita asked on December 12, 2024

We need to format cell text to have there specific things and not what flexmonster shows by default, and so we have `customizeCell` function:

    customizecellfunction: function (cell, data, rawdata) {
        var me = this;
        var valcol = data.type == "value" && data.label != "" && !scil.Utils.isNullOrEmpty(data.recordId);
        if ((!data.isGrandTotal && !data.isTotalColumn && valcol)
            || (!data.isGrandTotal && data.isTotalColumn && valcol && data.measure.aggregation == "count")) {
            ...
}
... },

The problem is that it disrupts correct default Flexmonster behavior which is erasing the data from the first row when its expanded and added only to the 2nd row (see the attached screenshot). We just need a way to distinguish between the first row when its not expanded and when it is expanded, and in the latter case erasing the data in the original row (default flexmonster behavior). 

pivot.report.slice.rows = [{ uniqueName: "EntityID" }, { uniqueName: "structureimage" }]

data.expanded is always false. We can check also data.level which will be 0 and 1 for two rows when a row is expanded, but then in the original state the level will be just 0 for all rows and so we would erase all data in the table if we try using it. 

Attachments:
expanded_issue_1.png

1 answer

Public
Maksym Diachenko Maksym Diachenko Flexmonster 4 days ago

Hello, Nikita!

Thank you for writing to us.

From the provided context, it seems that you have disabled row subtotals with the showTotals option, and want to prevent the customizeCell injecting data in that cell after it is expanded. To identify such cases, you can utilize the specifics of how customizeCell processes the cleared subtotal row - in such cases, the data.label parameter is equal to an empty string (""). By combining this with changing the number formatting for empty values, you can clearly identify the expanded row from other rows, including ones with empty cells.

We have prepared an example that illustrates this approach for distinguishing empty subtotal rows: https://jsfiddle.net/flexmonster/75pte9qj/

As for the data.expanded property being false, please note that the property is only working for header cells. As a result, it can not be applied to this case when the processing of value cells is needed.

Please let us know if this solution works for you.

Best Regards,
Maksym

Please login or Register to Submit Answer