Trouble in refresh data of Flexmonster

Answered
Angus Yu asked on March 17, 2023

Hi,
     I can load data for the first time but I can't refresh the data of flexmoster in Vue 2. Please help to solve the problem, thanks! I provide the error and coding (with attachment) at below.
[Error found in Chrome Console]
[Vue warn]: Error in created hook: "TypeError: Cannot read properties of undefined (reading 'flexmonster')"
 
[Coding]

<template>
  <div id="vue">
    <v-btn @click="LoadData" small text color="#6750A4" class="ml-2 mb-2" >
                                    {{ $t("message.resetBtn") }}
    </v-btn>
    {{ iData.length }}
  <Pivot
    ref="pivotContainer"
    toolbar
    height="800"
    v-bind:global="{
        localization: {
           grid: {
              blankMember: ''
           }
        }
    }"
    v-bind:report="{
    dataSource: {
        data: iData,
    },
    options: {
          grid: {
            type: 'flat',
            showTotals: 'off',
            showGrandTotals: 'off'

          },
        }

    }"
    v-bind:licenseKey="'XXXX-XXXX-XXXX-XXXX'">
  </Pivot>
</div>
</template>

<script>
import Pivot from "../components/Pivot"
export default {
    name: 'App',
    components: {
      Pivot
    },
    data: () => ({
        testData:[{    
        "Color" : "green","Country" : "Canada","State" : "Ontario","City" : "Toronto","Price" : 174,"Quantity" : 22
        },
        {
        "Color" : "red","Country" : "USA","State" : "California","City" : "Los Angeles","Price" : 166,"Quantity" : 19
        }],
        iData: null
    }),
    mounted() {
      //Nothing to do
    },
    created(){
         let _this = this;
         this.LoadData();
         
    },

    methods: {
      LoadData() {
        this.iData = "[]"
        //let results = this.$store.getters["dashboard/getDashboardData"].reportB;
        //console.log("results: ",  results);
        this.iData = this.testData;
       
        this.$refs.pivotContainer.flexmonster.updateData();
       
       
        //this.$refs.pivot.flexmonster.connectTo(this.iData);
        //this.$refs.iData = results;
        //this.$refs.pivotContainer.setReport(this.iData);
        //this.$forceUpdate();
        //flexmonster.refresh();
        /*
        this.$refs.pivotContainer.flexmonster.updateData({
          type: "json",
          filename: this.iData,
        });*/
       
        //this.connectJSON();
        debugger;      
       
      },
    }
  }
</script>

 
Angus Yu

3 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster March 17, 2023

Hello, Angus!

Thank you for your question.

We have looked through the provided example and prepared two recommendations that may help you to achieve the desired functionality:

  • You should avoid using the "created" lifecycle hook with Flexmonster API. Our component is not synced with Vue lifecycle hooks. It has its own ready event, triggered when the component's initial configuration is completed and ready to receive API calls. You can check the example of using the ready event in Vue in our GitHub sample project(UpdatingData.vue, line 32).
  • Please note that the updateData API call requires the DataSourceObject to be passed as its first parameter. Here is an example using the updateData for passing the JSON  data source with the data property:
this.$refs.pivotContainer.flexmonster.updateData({
type: "json",
data: jsonDataArray
});

Also, the import statement from your code example looks like you are importing the extended component based on vue-flexmonster. If this is the case and the suggestions above would not help, we recommend checking if this extension may contain something that can alter the Flexmonster's logic.

Looking forward to hearing your feedback.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster March 30, 2023

Hello, Angus!

Hope you are doing well.
Our team is wondering if you had time to check our previous reply.
Please let us know if the provided information helped you.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 11, 2023

Hello, Angus!

We would like to know if you tried to test the provided solutions.
Please let us know if these suggestions helped you.

Best Regards,
Maksym

Please login or Register to Submit Answer