hi :
when i use reportcomplete in a recursive loop, I encountered a problem !
the codes in the reportcomplete are launched several times !
you could find it by message in the console. (console.log)
could you help me plz ?
thanks !
I did a demo .
here is link :
http://jsfiddle.net/31Lvsn9p/75/
and there is demo code :
function getR() {
var report = {};
report['dataSource'] = {"data" : getData()};
return report;
}
function getData() {
return [{
"Color": "green",
"M": "September",
"W": "Wed",
"country": "Canada",
"state": "Ontario",
"city": "Toronto",
"Price": 174,
"Quantity": 22
}, {
"Color": "red",
"M": "March",
"W": "Mon",
"Time": "1000",
"country": "USA",
"state": "California",
"city": "Los Angeles",
"Price": 30,
"Quantity": 19
}];
}
var pivot = {};
pivot[0] = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData()
}
}
});
pivot[1] = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData()
}
}
});
pivot[2] = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData()
}
}
});
var nbReport = 3;
function reloadReport(n) {
pivot[n].setReport(getR());
console.log("out : " + n);
pivot[n].on('reportcomplete', function () {
console.log("in : " + n);
n++;
if (n < nbReport) {
reloadReport(n);
}
});
}
reloadReport(0);
Hi,
Thank you for posting to our forum and for sending the demo code and JSFiddle example.
We would like to explain that in the provided example, the reportcomplete
is triggered in two cases: when the setReport
method is called and when the instance of Flexmonster is defined. In the recursive loop, the number of events triggered increases. Therefore, the component behavior you described is expected.
In case the code inside the reportcomplete
handler should be launched one time, we suggest adding pivot[n].off('reportcomplete');
in the handler to achieve that.
Please find further info about the off method here: https://www.flexmonster.com/api/off/.
If the suggested API call does not work for your case, could you please tell us some details about the logic you are implementing in the reloadReport
function? This will help us to provide you with the most relevant solution.
Waiting for your reply.
Kind regards,
Milena
thanks for your explications and suggestion .
I'll try it.
I will let you know !
kind regards,
Long
Hi, Long,
How are you?
We were wondering if our response helped you with your question.
Could you please let us know if the suggested approach works for you?
We would be happy to hear your feedback.
Kind regards,
Milena
Hello, Long,
Hope you are doing well.
We are just checking in to ask if you have managed to achieve the desired component behavior regarding the reportcomplete
event.
Looking forward to hearing from you.
Best regards,
Milena