I have the GetOptions returning null because I'm using a parent - child component relationship that triggers the Onchange and causes it to return null. I however assign a value to the options within my report but option still null which is weird
Hello, Oladipo!
Thank you for reaching out to us.
Kindly note that the getOptions
API call returns all default options, even if none were explicitly specified. Hence, the most likely scenario of this method returning null
is when the component is still not initialized. We suggest wrapping the getOptions
call within the reportcomplete
event to ensure that the component is ready to return options properly. To see how to use the Flexmonster events in angular, please check this GitHub sample.
Please let us know if our recommendations were helpful.
Best Regards,
Maksym
It is not based on an event from the html, and using the reportcomplete
runs every time per second. We ended up using Ready(), but sometimes, the options would still be null. Do you have an implementation with the OnChange event call within Angular?
Hello, Oladipo!
Thank you for your reply.
Please note that the ready
event indicates that the Flexmonster's instance is ready to receive API calls, but all configurations may not have been completed. Hence, the getOptions
API call can be inconsistent before the reportcomplete
event was fired. Speaking of the reportcomplete
event handler running recurrently, this could occur due to setReport
event being called inside the event handler.
Could you please send us the sample project or code snippets where this issue with the getOptions
method can be reproduced. This would greatly help us to understand your case and provide better assistance.
Looking forward to hearing from you.
Best Regards,
Maksym
what event handler do you mean here?
Speaking of the reportcomplete
event handler running recurrently, this could occur due to setReport
event being called inside the event handler.
Hello, Oladipo!
Thank you for your reply.
We apologize for the incorrect information provided in the previous message. What we meant to reference was that when the setReport
API call is used in the reportcomplete
event handler, it triggers the reportcomplete
event again recursively. This was mentioned since you reported that reportcomplete
runs every time per second.
Nevertheless, to better assist you with your inquiry, it would be helpful if you could provide us with the code snippet where you are attempting to use the getOptions
method, and it returns null
.
Looking forward to hearing from you.
Best Regards,
Maksym
I got it to stop when I unsubscribe from the reportcomplete event handler.
this.pivotRef.flexmonster.off('reportcomplete');
However, I noticed that the reportComplete method doesn't run smoothly as the Ready() event function. It keeps the old data and configurator settings which would make me prefer the Ready() event. So basically this is how the code logic looks like :-
onReportComplete() {
if (this.ObjExists) {
this.ChangeConfiguratorStatus(true); // this would show the field popup
this.reportQuery.slice = null;
this.reportQuery.options.showDefaultSlice = false;
}
else {
this.ChangeConfiguratorStatus(false);
this.reportQuery.slice = this.PopulateSlice();
this.reportQuery.options = this.PopulateOptions();
this.reportQuery.formats = this.PopulateFormats();
}
this.pivot.flexmonster.setReport(this.reportQuery);
}
ChangeConfiguratorStatus(status: boolean): void {
let myOptions = this.pivot.flexmonster.getOptions();
myOptions.configuratorActive = this.reportQuery.options.configuratorActive = status;
this.pivot.flexmonster.setOptions(myOptions);
this.reportQuery.options = myOptions;
}
Now if you switch this handler to the Ready() handler, then I shouldn't be able to get the options from the ChangeConfiguratorStatus method.
Hello, Oladipo!
Thank you for sharing this information with us.
Kindly note that in this case, there is no need to set the options, as is done in the ChangeConfiguratorStatus
method. This is due to them being overwritten when setting a whole report in this line of code:
this.pivot.flexmonster.setReport(this.reportQuery);
Hence, you can simplify the code by just setting the reportQuery.options.configuratorActive
before the setReport
method is called without using getOptions
/setOptions
methods. In addition, by removing the reliance on getOptions
you will be able to use the ready
handler instead of reportcomplete
.
Please let us know if our recommendations were helpful.
Best Regards,
Maksym
Hello, Oladipo!
Hope you are doing well.
Please let us know if our suggestions regarding your use case were helpful.
Looking forward to hearing from you.
Best Regards,
Maksym
Hello, Oladipo!
We are checking in to ask whether you still face any issues related to this use case.
Please feel free to share your feedback.
Best Regards,
Maksym
We got it working, but wasn't through your suggested approach.
Hello, Oladipo!
Thank you for your reply.
We are glad to hear that you resolved the issue on your end.
Feel free to contact us if more questions arise.
Best Regards,
Maksym