Hi,
I am
using the TreeGrid component and binding the data from the vuex store - means
it acts like local dataSource.
In the vuex store I have the data, which is empty, and this data is fetched
from the server when loading the application. I also have isLoading variable, to
indicate the loading data state.
I am calling the TreeGrid showSpinner() and hideSpinner() according to the
value of the isLoading variable in the store.
I have multiple issues:
Please advise.
Thanks,
store.js:
import { createStore } from 'vuex'
const store = createStore({
state: {
data: [],
isLoading: false
},
getters: {
data: state => state.data,
isLoading: state => state.isLoading
},
actions: {
loadData({ commit }) {
commit('setisLoading', true)
fetch(url, requestObject).then(data => {
commit('setData', data)
commit('setisLoading', false)
})
},
},
mutations: {
setData(state, data) {
state.data = data
},
setisLoading(state, isLoading) {
state.isLoading = isLoading
},
},
strict: true
})
export default store
MyTreeGrid.vue:
<template>
<ejs-treegrid
ref="treegrid"
:dataSource="data"
:columns='columns'
height='100%'
treeColumnIndex='1'
idMapping="id"
parentIdMapping="parentId"
hasChildMapping="hasChildren">
</ejs-treegrid>
</template>
<script>
import {mapActions, mapGetters} from "vuex";
export default {
data() {
let columns = [
{field: 'name', headerText: 'Name', textAlign: 'Left', width: 180 },
{field: 'owner', headerText: 'Owner', textAlign: 'Left', width: 90, },
{field: 'creation_time', headerText: 'Creation Date', textAlign: 'Right', width: 90, type: "Date", format: 'dd/MM/yyyy hh:mm a' },
]
return {
columns,
}
},
computed: {
...mapGetters( [
"data",
"isLoading"
]),
},
watch: {
isLoading(value) {
if (value) {
this.$refs.treegrid.showSpinner();
} else {
this.$refs.treegrid.hideSpinner();
}
}
},
}
</script>
The 2 shown spinners in the TreeGrid:
|
<style>
.e-treegrid .e-spinner-pane {
display: none;
}
</style> |
Hi,
Thanks for your help. What I will do is to hide the default spinner of the TreeGrid, and add my own customized spinner.
For that purpose, I am using your Spinner component, and want to append it to the TreeGrid’s header. I am doing the following:
<template> <ejs-treegrid ref=”treegrid” :dataSource="data" :columns=”columns” :created=”onCreated”></ejs-treegrid>
</template>
<script>
import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-vue-popups';
import { data, columns } from ‘./source.js’
export default { data() { return { data: data,
columns: columns,
};
},
methods: {
createSpinner() {
createSpinner({
target: this.$refs.treegrid.$el.getElementsByClassName("e-gridheader")[0]
})
},
showSpinner() {
showSpinner(this.$refs.treegrid.$el.getElementsByClassName("e-gridheader")[0])
},
hideSpinner() {
hideSpinner(this.$refs.treegrid.$el.getElementsByClassName("e-gridheader")[0])
},
onCreated() {
this.createSpinner()
}, },
};
</script>
Now, I need to show / hide the customized spinner by using the TreeGrid events. Which events should I use?
Thanks,
Thank you for your help.