Articles in this section
Category / Section

How to pass Vuex store instances to child components within the Vue Query Builder template?

2 mins read

Overview

When working with Vue.js and Syncfusion’s Query Builder component, you may need to integrate Vuex for state management. This article demonstrates how to pass Vuex store instances to child components within the Query Builder.

Passing Vuex Store Instances

To pass the Vuex store instance to a child component, you can directly reference $store in the HTML template. This allows you to access the Vuex state within the child component.

Code Snippet

Here is an example of how to pass the Vuex store instance to a child component within the Syncfusion Query Builder component:

index.vue:

<template>
  <ejs-querybuilder :rule="importRules" ref="querybuilder" width="100%">
    <e-columns>
      <e-column field='Date' label='Date' type='date' :template="'dateTemplate'">
        <template v-slot:dateTemplate="{data}">
          <child :store='$store'></child>
        </template>
      </e-column>
    </e-columns>
  </ejs-querybuilder>
</template>

child.vue:

<script>
export default {
  name: "child",
  props: ['store'],
  mounted() {
    console.log(this.store.state.m.token);
  }
}
</script>

In the above example, the child component receives the Vuex store instance as a prop. This allows the child component to access the Vuex state, such as this.store.state.m.token, and perform actions or retrieve data as needed.

Conclusion

By passing the Vuex store instance directly in the template, you can easily integrate Vuex within the Syncfusion Query Builder component. This approach simplifies state management and ensures that your components have access to the necessary data.

Additional References

Remember to consult the official documentation for the most up-to-date and detailed information.

QueryBuilder.zip
Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied