Questions about errors encountered while applying vue-flexmonster

Answered
hoobeom lee asked on June 21, 2023

hello,
I'm trying to apply vue-flexmonster, but there's an undefined error in accessing the flexmonster object using reference for update.

<Pivot
toolbar
ref="pivot"
height="600"
v-bind:report="pivotData"
v-bind:update="drawTable"
v-bind:shareReportConnection="{ url: 'https://olap.flexmonster.com:9500' }"
v-bind:beforetoolbarcreated="customizeToolbar"
v-bind:licenseKey="key"/>

As above, the information entered in the report property does not work even if the data changes after mount.

vm.pivotData = {
dataSource: {
data: vm.bindingData
},
slice: {
pages: vm.pages,
rows: vm.rows,
columns: vm.columns,
measures: vm.measures,
expandAll: true
},
formats: vm.formats,
options: {
"grid": {
"showTotals": "off",
"type": "classic"
}
}
}

vm.$refs.pivot.flexmonster.updateData(vm.pivotData);

So when I try to use the updateData function, I can't access the flexmonster object and get an undefined error.
 
Flexmonster pivots are used as components, and bindingData implements update data as properties of components through watch.
 
I need you to tell me how to solve it.
 
thank you
 
 

Attachments:
캡처.PNG

7 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster June 22, 2023

Hello, Hoobeom Lee!
 
Thank you for reaching out to us.
 
Our team kindly suggests checking out our updating data sample in Vue as an entry point: https://github.com/flexmonster/pivot-vue/blob/master/vue2/ES6/src/views/VueFlexmonsterExamples/UpdatingData.vue.
This sample is a part of our Vue2&Vue3 example project: https://github.com/flexmonster/pivot-vue/tree/master.
 
We also want to point your attention to the updateData() API call, which takes the dataSource object as a parameter:

vm.$refs.pivot.flexmonster.updateData(vm.pivotData.dataSource)

You can read more about this API call in our docs: https://www.flexmonster.com/api/updatedata/.
 
Hope you will find our answer helpful. Please let us know if you have any further questions.
 
Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster July 4, 2023

Hello!

Hope you are having a great week.

Our team is wondering if you had some time to check out our Vue sample with the updateData() function. Could you please let us know if it was helpful?

Looking forward to hearing from you.

Kind regards,
Solomiia

Public
hoobeom lee July 5, 2023

Hello.
First of all, I'm sorry for the late reply.
 
The error persists even though it was reflected as guided.
 
The parameters of the updateData function may also be a problem, but the larger problem is that the flexmonster object in the pivot reference is recognized as undefined.
 
Please check the attached file, and the contents below are the source code.
 
 

<template>
<div id="app">
<Pivot
v-if="bindingData.length !== 0"
toolbar
ref="pivot"
v-bind:height="600"
v-bind:shareReportConnection="{ url: 'https://olap.flexmonster.com:9500', }"
v-bind:beforetoolbarcreated="customizeToolbar"
v-bind:ready="onReady"
_v-bind:licenseKey="key"/>
<!-- v-bind:report="pivotData"-->
</div>
</template>

<script>
import Vue from "vue";
import Pivot from "vue-flexmonster";
import 'flexmonster/flexmonster.css';

Vue.use(Pivot);

export default {
name: "stats-component",
props: {
pages: {
type: Array
},
rows: {
type: Array
},
columns: {
type: Array
},
measures: {
type: Array
},
bindingData: {
type: Array
},
formats: {
type: Array
}
},
components: {
Pivot,
},
data: function () {
return {
key: String,
pivotData: {
dataSource: {
type: 'json',
data: this.bindingData
},
slice: {
pages: this.pages,
rows: this.rows,
columns: this.columns,
measures: this.measures,
expandAll: true
},
formats: this.formats,
options: {
"grid": {
"showTotals": "off",
"type": "classic"
}
}
},
}
},
watch: {
bindingData: {
handler() {
this.drawTable();
}
}
},
mounted() {
let vm = this;
vm.$ajax({
url: '/flexmonster/key',
type: "GET",
success: function (value) {
if (value) {
vm.key = value;
} else {
vm.$commonUtils.alertDialog(vm.$message['alert.system.error']);
}
}
});
},
methods: {
drawTable() {
const vm = this;

if (vm.bindingData === undefined || vm.bindingData.length === 0) {
vm.$commonUtils.alertDialog("해당조건의 데이터가 없습니다.");
return;
}

console.log(this.bindingData);
vm.$refs.pivot.flexmonster.updateData(vm.pivotData.dataSource);
},
onReady: function () {
const vm = this;
vm.$refs.pivot.flexmonster.connectTo(vm.pivotData.dataSource);
},
customizeToolbar: function (toolbar) {
toolbar.showShareReportTab = true;
},
}
}
</script>

Attachments:
캡처.PNG

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster July 5, 2023

Hello!
 
Thank you for providing us with the new code snippet.
 
Kindly note that depending on how often the bindingData is updated, the watcher may call the drawTable() function before the onReady Flexmonster event is triggered. Therefore, there is no $refs.pivot.flexmonster instance, as the component is not created yet.
 
We suggest checking if the $refs.pivot.flexmonster instance exists before running the drawTable(). It is also a good idea to wrap the function with updateData() in reportcomplete event, so Flexmonster can finish rendering the previous report before the data is changed.
For example, it can be done as follows:

 watch: {
        bindingData: {
            handler() {
                if (this.$refs.pivot && this.$refs.pivot.flexmonster) {
                    this.$refs.pivot.flexmonster.on("reportcomplete", () => {
                        this.$refs.pivot.flexmonster.off("reportcomplete");
                        this.drawTable();
                    });
                }
            }
        }
    },

 
If you are loading bindingData from your endpoint using Ajax, we kindly suggest checking out the following example: https://jsfiddle.net/flexmonster/2qb8wzh1/. It may be helpful for your use case.
 
Hope you will find our answer helpful.
Please let us know if you have any further questions.
 
Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster July 13, 2023

Hello, Hoobeom Lee!

Hope you are doing well.

Just checking in to ask if you had a chance to try the suggested approach and update data in Vue using Flexmonster events. Could you please let us know if it works well for your case?

Looking forward to hearing your feedback.

Kind regards,
Solomiia

Public
hoobeom lee July 14, 2023

Hello.
Unfortunately, the conditional statement you guided is not carried out.
It is guess that the reference of the if condition is also recognized as undefined.
We are avoiding the use of references due to issues arising from rendering timing of doms, but we have challenged how to use references because there was no other way in vue-flexmonster's guide.
Is there any other way not to use references?
If there is no other way, I will put the transition process to vue-flexmonster on hold, and try to keep it as it is.
 
thank you
 

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster July 14, 2023

Hello, Hoobeom Lee!

Thank you for your response.

Kindly note that using Flexmonster API calls in Vue is possible only using reference.

Feel free to contact us if any other questions arise.

Kind regards,
Solomiia

Please login or Register to Submit Answer