Need a special offer?Find out if your project fits.
+

How to check if returned data is empty? without using showEmptyData property

Answered
Abhilash asked on January 22, 2021

Hello,
i would like to check if returned data is empty, i.e. we get the csv headers but no entries.
can i access the data in report and do something like getRowSize() / getNumberOfRows() and if this is 0 act on it?
But i don't want to use showEmptyData: false because it will create flexmonster with error box "Data source is empty" my goal is to completely hide the flexmonster away and show No data found message.
 
Thanks

3 answers

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster January 25, 2021

Hi Abhilash,
 
Thank you for posting your question.
 
One way of doing this with CSV is to use the getMembers() API call to check whether the fields have any members once the data is loaded to the pivot table. In case the data set is empty (only containing headers), applying getMembers() on its fields will result in empty arrays.
 
Alternatively, in case your CSV file is loaded to the pivot table from a server, you could also try checking whether the data set is empty on the server-side prior to passing it to Flexmonster.
 
Please let us know if this helps.
 
Best regards,
Mykhailo

Public
Abhilash January 25, 2021

So i have around 32 columns. I should do this on all column headers and check if it's empty array? Hmm doesn't seem ideal. 
I just added this.pivot.flexmonster API call to check if data is empty. It's working good now. Hope this is ok?

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster January 26, 2021

Hi Abhilash,
 
Thank you for your response.
 
It is good to hear you've found a solution that suits you!
 
As always, feel free to reach out in case there is anything else we can help you with.
 
Best regards,
Mykhailo

Please login or Register to Submit Answer