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

auto repeat is possible?

Answered
Fabrizio asked on December 5, 2022

Good morning
when my data in flexmonster pivot with hierarchy is like this
 
[G1: Reddito Netto, G2.... G3...G4...G5...G6...G7: Parcheggio, G8:null,  Value: 18.883]
and another data-row
[G1: Reddito Netto, G2.... G3...G4...G5...G6...G7: Parcheggio, G8:Transfer,  Value: 18.883]
the pivot will return me a empty field in row.
Is possible to repeat automatically the father field
 
Please see in attachment
 
Thanks
Daniele

Attachments:
screen_tobe.jpg

14 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster December 6, 2022

Hello, Daniele,

Thank you for reaching out to us.

We suggest using the customizeCell() API call to have the desired result. Kindly check the following JSfiddle for reference: https://jsfiddle.net/flexmonster/2z61x0ps/ 
In the example above, we used the data.rows and data.level properties of the CellDataObject to get the caption of the parent.

Please let us know if it works for you. Feel free to contact us if other questions arise.

Kind regards,
Nadia

Public
Fabrizio December 12, 2022

Hi Nadia,
I've tried your solution but the script give me an error.
I've copied all my code in a page where you can try.
****
I attach the screen where you can see the exactly point
Can you help me? Thanks 

Attachments:
screen.JPG

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster December 13, 2022

Hello, Fabrizio,

Thank you for providing us with the code.

The error appeared due to the hierarchy. Therefore, we suggest the following workaround using the getMembers API call and the custom recursive search to find the corresponding caption of the parent:

function customizeCellFunction(cell, data) {
if (data && data.type == "header" &&
    data.member && data.label == " ") {
    let parentName = data.rows[0].parentMember;
    let members = flexmonster.getMembers("G");
    cell.text = recursiveSearch(members, parentName)
  }
}

Please you are free to use the following function: 

function recursiveSearch(members, parent) {
  for (let mmb in members) {
    if (parent === members[mmb].uniqueName) {
      return members[mmb].caption;
    }
    if (parent.startsWith(members[mmb].uniqueName)) {
      return recursiveSearch(members[mmb].children, parent);
    }
  }
}

Kindly note that we described only one of the possible approaches. You are welcome to customize it for your needs.

Please let us know if it works for you. Looking forward to hearing from you.

Kind regards,
Nadia

Public
Fabrizio December 14, 2022

Nadia thanks a lot!!!
It's perfect!
Kiss

Public
Fabrizio December 14, 2022

I've one more question for you..... the last question!
at the same URL https://dev.goprofit.cloud/gest/flexmonster.php 
Is possible to exclude "Reddito Netto" G1 in the hierarchy and "Anno" from the collapse method and keep G1 and G2 always opened?
 

Attachments:
screen.JPG

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster December 15, 2022

Hello, Fabrizio,

Thank you for the response.

We recommend making the following report adjustments to achieve the functionality shown in the screenshot:

  • Remove the "Anno" field inside the slice.columns. This way, the "Mese" field would be on top.
  • To hide the "Reddito Netto", you should set the "G2" field as a top-level field of the "G" hierarchy. If needed, you can exclude the "G1" from the Fields list with the "visible": false setting. You are welcome to see the code example below:
"mapping": {
        "G1": {
          "visible": false
        },
        "G2": {
          "hierarchy": "G"
        },
        "G3": {
          "hierarchy": "G",
          "parent": "G2"
        },
        //Other...
}
  • To expand the "G2" top-level fields, add the drills object to your slice configuration with the following settings: 
"drills": {
        "rows": [{
            "tuple": [ "g.[ ebitda]" ]
          }, {
            "tuple": [ "g.[deprezzamenti]" ]
          }
        ]
}

Please let us know if the suggested approach helped you. Looking forward to your response.

Kind regards,
Nadia

Public
Fabrizio December 17, 2022

Hi Nadia,
I've tried your code but this can't be the solutions for me for two problems:
1 . I have to see the G1 level "Reddito Netto"
2. The year must to be visible because if my report include for example nov and dec of 2022 anche jan and feb of 2023 I'va to see this informations.
I'm sorry 🙁

Public
Maksym Diachenko Maksym Diachenko Flexmonster December 19, 2022

Hi, Fabrizio!

Thank you for your feedback.

If we understood correctly, you would like to have the top member in rows ("Reddito Netto" G1), and the top field in columns ("Anno") expanded by default and then hide the expand/collapse arrow icons to prevent them from being collapsed. To achieve this, we suggest the following solution:

  1.  To keep certain hierarchies expanded, you can set the expands into the slice or use the expandData() API call. We recommend expanding the needed cells via UI, saving the report with the "Save" toolbar tab, and copying the saved drills and expands into your report configuration. 
  2. You can remove the expand/collapse icons and prevent the collapse/expand action with the customizeCell method. You are welcome to check the following example: https://jsfiddle.net/flexmonster/egxc94yt/

Please let us know if the suggested approaches worked for you.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster December 27, 2022

Hello, Fabrizio!

Hope you are doing well.
We are wondering if you had time to check the provided solutions.
Please let us know if they worked for you.

Best Regards,
Maksym

Public
Fabrizio December 27, 2022

Hello Maksym,
thanks for you response to my Ticket.
I've tried your solution but I have one problem. You use the value of the first data cell for eclude the arrow for collapse after the expand command.
The problem is: my data result is variable and the data value of first cell is different for any request. Is possible to hide the collapse arrow using the mapping? For example using G1?
my configuration is 

mapping: {
                G1: {
                    hierarchy: "G"
                },
                G2: {
                    hierarchy: "G",
                    parent: "G1"
                },
                G3: {
                    hierarchy: "G",
                    parent: "G2"
                },
                G4: {
                    hierarchy: "G",
                    parent: "G3"
                },
                G5: {
                    hierarchy: "G",
                    parent: "G4"
                },
                G6: {
                    hierarchy: "G",
                    parent: "G5"
                },
                G7: {
                    hierarchy: "G",
                    parent: "G6"
                },
                G8: {
                    hierarchy: "G",
                    parent: "G7"
                },
                G9: {
                    hierarchy: "G",
                    parent: "G8"
                },
                G10: {
                    hierarchy: "G",
                    parent: "G9"
                },
                G11: {
                    hierarchy: "G",
                    parent: "G10"
                }
            }

Thanks

Public
Maksym Diachenko Maksym Diachenko Flexmonster December 30, 2022

Hi, Fabrizio!

Thank you for your reply.

For dynamic data, the same functionality can be achieved by adjusting the customizeCell function. Since, in your scenario, the cell's member name may differ, you can remove the condition for data.label in the previously provided example. The remaining conditions for removing the expand/collapse icon should be similar to these:

data.hierarchy.uniqueName == "Data" && data.level === 0

This condition checks if the cell is a top-level field of the multilevel hierarchy. 

Also, since in G1 and G2 the values may change, we would suggest a more dynamic way to expand the first level instead of explicitly specifying expands in the report configuration. For instance, it is possible to use the getMembers() API call to retrieve and expand certain hierarchy levels dynamically. Please check the following example (setDrills() function, line 57): https://jsfiddle.net/flexmonster/yjzbuht3/

We hope this helps. Please let us know if you have any other questions.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster January 10, 2023

Hi, Fabrizio!

Hope you are doing well.
Could you please let us know if the suggested approaches for expanding cells and removing the expand/collapse icons from certain hierarchy levels work for you?
Looking forward to hearing from you.

Kind Regards,
Maksym

Public
Fabrizio January 12, 2023

Hi Maksym,
the code is perfect!
 
Thanks
Fabrizio

Public
Maksym Diachenko Maksym Diachenko Flexmonster January 12, 2023

Hi, Fabrizio!

Thank you for your feedback.
Our team is glad to hear that the suggested solution worked for you.
Please let us know if any other questions arise.

Best Regards,
Maksym

Please login or Register to Submit Answer