Dear visitor, despite the COVID-19 outbreak, our team continues operating at full speed.

Also, here is the form where you can apply for a special discount and we will contact you with possible options. Stay safe and continue achieving your business goals.

Fill the form
Get Free Trial
Get Free Trial

When no data/columns is provided, hide 'Fields' modal

Answered
Patrick Berens asked on February 26, 2020

Hiya Flex Team,
We are using Flat View to display some data and we have the toolbar hidden. However, sometimes our JSON response comes back like the following:
 

"data":[{"hiddenHeader":{"type":"hidden"}}]

 
In this case, the ‘Fields’ selector pops up. Is there a way to disable this permanently for a Flexmonster instantiation? We use it on other pages, but for this page we just use the Flat View to display data and we’d like it to show as empty (“spreadsheet” look).
 
I’ve attached a picture of the bad state we’d like to avoid.
 
Thanks,
Patrick
 

Attachments:
fields_modal.png

3 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster February 27, 2020

Hello, Patrick,
 
Thank you for reaching out to us.
 
The described behavior can be achieved using two approaches.
 
The Field List will not be opened in case the dataSource object is missed or does not contain data or filename property. In such a situation, an empty grid will be shown.
 
However, as we can see from your question, the JSON response is not always empty, and the filename property is required. In this case, our team suggests embedding of following code snippet to the page:

pivot.on('reportcomplete', function() {
    pivot.off("reportcomplete");
    if (pivot.getAllHierarchies().length == 0)
        pivot.setReport(pivot.getReport().dataSource = {});
});

The block of code provided above is executed when the reportcomplete event is triggered. It scans all hierarchies presented in the data set and modifies the dataSource object in case the data set does not contain any hierarchies, thereby the Field List is not opened, and the empty spreadsheet is displayed.
 
Please refer to an example we have prepared for you.
 
More information about API calls and object used in the example:

 
We hope it works for you.
 
Please contact us in case any additional questions occur.
 
Best regards,
Illia

Public
Patrick Berens March 2, 2020

Thanks, we hacked around on BE and wiped the header when no data is returned.
 
THanks again,
Patrick

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster March 3, 2020

Hello, Patric,
 
Thank you for your feedback.
We are happy to hear you have managed to achieve the desired result.
 
Do not hesitate to contact us in case other questions arise.
 
Kind regards,
Illia

Please login or Register to Submit Answer