Loading animation in Vue Treegrid component
11 Jun 20245 minutes to read
The Tree Grid displays a loading indicator while the data is being fetched and bound to the tree grid during initial rendering, refreshing, and after performing any tree grid actions like sorting, filtering, and more.
The tree grid supports two indicator types, which can be enabled by setting the loadingIndicator.indicatorType
property to Spinner or Shimmer. The default value of the indicator type is Spinner.
In the following sample, the Shimmer indicator is displayed while the tree grid is loading and refreshing when using the remote data.
<template>
<div id="app">
<ejs-treegrid :dataSource="data" idMapping='TaskID' parentIdMapping='ParentItem' hasChildMapping='isParent' :treeColumnIndex='1' :allowPaging='true' :allowSorting='true' :pageSettings='pageSettings' :loadingIndicator='loadingIndicator'>
<e-columns>
<e-column field='TaskID' headerText='Task ID' width=120 textAlign='Right'></e-column>
<e-column field='TaskName' headerText='Task Name' width=240 textAlign='Left'></e-column>
<e-column field='StartDate' headerText='Start Date' width=140 format="yMd" textAlign='Right' type='date'></e-column>
<e-column field='Duration' headerText='Duration' width=130 textAlign='Right'></e-column>
<e-column field='Progress' headerText='Progress' width=130></e-column>
</e-columns>
</ejs-treegrid>
</div>
</template>
<script setup>
import { provide } from "vue";
import { TreeGridComponent as EjsTreegrid, Page, Sort, ColumnDirective as EColumn,
ColumnsDirective as EColumns
} from "@syncfusion/ej2-vue-treegrid";
import { DataManager, WebApiAdaptor } from "@syncfusion/ej2-data";
let SERVICE_URI ="https://services.syncfusion.com/vue/production/api/SelfReferenceData";
const data = new DataManager({
url: SERVICE_URI,
adaptor: new WebApiAdaptor(),
crossDomain: true
});
const pageSettings = { pageCount: 3 };
const loadingIndicator = { indicatorType: 'Shimmer' };
provide('treegrid', [ Page, Sort ]);
</script>
<template>
<div id="app">
<ejs-treegrid :dataSource="data" idMapping='TaskID' parentIdMapping='ParentItem' hasChildMapping='isParent' :treeColumnIndex='1' :allowPaging='true' :allowSorting='true' :pageSettings='pageSettings' :loadingIndicator='loadingIndicator'>
<e-columns>
<e-column field='TaskID' headerText='Task ID' width=120 textAlign='Right'></e-column>
<e-column field='TaskName' headerText='Task Name' width=240 textAlign='Left'></e-column>
<e-column field='StartDate' headerText='Start Date' width=140 format="yMd" textAlign='Right' type='date'></e-column>
<e-column field='Duration' headerText='Duration' width=130 textAlign='Right'></e-column>
<e-column field='Progress' headerText='Progress' width=130></e-column>
</e-columns>
</ejs-treegrid>
</div>
</template>
<script>
import { TreeGridComponent, Page, Sort, ColumnDirective, ColumnsDirective } from "@syncfusion/ej2-vue-treegrid";
import { DataManager, WebApiAdaptor } from "@syncfusion/ej2-data";
export default {
name: "App",
components: {
"ejs-treegrid":TreeGridComponent,
"e-columns":ColumnsDirective,
"e-column":ColumnDirective,
},
data() {
let SERVICE_URI ="https://services.syncfusion.com/vue/production/api/SelfReferenceData";
return {
data: new DataManager({
url: SERVICE_URI,
adaptor: new WebApiAdaptor(),
crossDomain: true
}),
pageSettings: { pageCount: 3 },
loadingIndicator: { indicatorType: 'Shimmer' },
};
},
provide: {
treegrid: [ Page, Sort ]
},
}
</script>