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

Suppress alert error message on dataerror

Answered
Serban Vasile asked on March 3, 2020

Currently we have error handling in case the web service that feeds the pivot is replying with a blank payload (csv in our case).
We did that because a blank payload doesn’t mean an error for us. It just means that the database filter we applied didn’t return records.
We now have a need to not display an error message at all in case the payload is blank.
How do we do that? We tried suppressing the alert from the code below, and returning true from the onDataError handler, but at that point the default error message from FlexMonster still took over (and that is a monster of a messagebox, with stuff that our users would never understand).
Please help us, this might seem like a little issue but it’s becoming a big one for our scenario where we show more than one pivot on the page, and pivot 3 out of 3 is failing, all the way at the bottom of the page. If we don’t click on the confirmation alert, even if we bring valid data in the next call, the pivot with data is still behind the prior alert.

onDataError = function (e, idx: number = -1) {
    console.log(‘Data error.’);
    this.progressSpinnerShown = false;
    // Changed below for Test Rule. 
    //if (e.error === “”) {
    if (e != undefined && e.error != undefined) {
      this.pivot1.flexmonster.alert({
        title: “Data Error”,
        message: (e.error === ” ? “Filter returned no data.” : e.error),
        type: “error”,
        buttons: [{ 
          label: “OK”, 
          handler: function() { console.log(‘Data Error Acknowledged by User’); } 
        }],
        blocking: false
      });  
    }
    return true;
    //this.updateReportUsage(‘Error’, e.error);
  };

5 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster March 4, 2020

Hello, Serban,

Thank you for reaching out to us.
 
Thank you for reporting about the problem. We have managed to reproduce it on our side.
 
The fix is going to be provided with a minor update ETA Mar 23. Loading an empty CSV file will entail the display of an empty grid without any alerts. Please let us know if such behavior will be appropriate for you.
 
As a workaround for now, we recommend using an approach demonstrated in the following code snippet:

pivot.on('dataerror', function () {
    pivot.on('reportcomplete', function (e) {
        document.querySelector("#fm-alert-view > div.fm-ui-element.fm-ui.fm-content > div > a").click();
    });
});

The dataerror event is triggered when some error occurred during the loading of data. It covers the case with an empty CSV file as well. As soon as the report is loaded (reportcomplete event), the “Ok” button on the alert will be programmatically pressed, and the alert will be closed.
 
We hope it works for you.
 
Do not hesitate to contact us in case additional questions occur.
 
Best regards,
Illia

Public
Serban Vasile March 5, 2020

As always, you guys rock!
It’s refreshing to see you answer our needs so quickly.
A couple of comments on the observations above:

  • Tried the workaround, it didn’t help me, didn’t work. First, because I develop in Angular, had to type cast to HTMLElement, otherwise typescript told me element didn’t have click available. Secondly, it didn’t kill my custom alert, at which point I was thinking that the code should work in case of the normal error message Flexmonster shows, the one I call the monster message :). I will try that one, let you know if it works.
  • Forgot to mention in my ticket that when there is no data in the payload, Flexmonster also sends an error message on the console. That throws us off all the time (we see red in the console, we get anxious :)). Can you also take care of that error when suppressing the error message? Also, if we would need sometimes to acknowledge the error, it would be fantastic if there were a flag to allow the error to show or not, and also if it worked not only for csv payloads, but also, at least for json payloads.

The console error message is this, for Flexmonster Version 2.8.1 (build 02/24/2020 13:29:30) :
flexmonster.full.js:9 TypeError: Cannot read property ‘TC’ of null
at r0m.Ll (flexmonster.full.js:9)
at r0m.FC (flexmonster.full.js:9)
at o4w.<anonymous> (flexmonster.full.js:9)
at o4w.L3p.dispatch (flexmonster.full.js:9)
at o4w.mD (flexmonster.full.js:9)
at o4w.$p (flexmonster.full.js:9)
at XMLHttpRequest.xhr.onreadystatechange (flexmonster.full.js:9)
at XMLHttpRequest.wrapFn (zone.js:1281)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:26247)
 
 

Public
Serban Vasile March 5, 2020

The click workaround worked but I had to move the code into the dataError handler, because reportComplete doesn’t fire when the blank payload is received.
It’s good for now as a workaround, with the exception of a quick flash for the window.
Also, as a comment, for others that read here…it seems idiotic to open the alert box only to click OK after that. First, one can do that selectively, based on different application contexts. Second, if we didn’t open the alertbox, the normal FlexMonster error message would still be there. That one flashes on the screen, too, by the way.

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster March 5, 2020

Hello, Serban.
 
Thank you for your feedback.
 
We are happy to hear that you have managed to find a temporary workaround.
 
As for the error in the console, we have noticed it as well. Both an alert issue and the mentioned exception are going to be fixed.
 
Talking about the flag allowing to show the error alert in case the received data set appeared empty, we would like to kindly draw your attention to the showEmptyData property of the options object. Setting its value to true allows achieving such behavior for CSV files with only the header specified. It is going to do the same with empty CSV files with a specified minor release.
More about options object and its properties can be found by the link.

flexmonster.on('reportcomplete', () => {
if (flexmonster.getAllHierarchies().length == 0)
flexmonster.alert({
title: 'The data set is empty',
type: 'error'
...
})
});

Also, we will consider adding the possibility to enable such an alert for JSON data sets. As for now, our team recommends using the following workaround:
You are welcome to check out an example demonstrating an approach described in the code snippet above.
It uses the getAllHierarchies API call in order to trigger the alert. In case the data set is empty, the getAllHierarchies returns an empty array. More information about the method itself in our documentation.
 
We hope it works for you.
 
Please contact us in case of additional questions.
 
Best regards,
Illia

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster March 24, 2020

Hi Serban,
 
We are happy to let you know that loading empty CSV/JSON data was made consistent.
 
This is available in the 2.8.3 version of Flexmonster: https://www.flexmonster.com/release-notes/
Now an empty grid will be displayed if an empty JSON object (“” or “[]”) is passed to Flexmonster.
 
You are welcome to update the component: https://www.flexmonster.com/doc/updating-to-the-latest-version/
 
Please feel free to reach out to us if you have any questions we can help you with.
 
Best regards,
Mykhailo

Please login or Register to Submit Answer