|
App.vue
methods: {
toolbarClick: function(args) {
//debugger;
if (args.item.id === "Grid_excelexport") {
// 'Grid_excelexport' -> Grid component id + _ + toolbar item name
this.$refs.grid.excelExport();
}
if (args.item.id === "Grid_pdfexport") {
// 'Grid_pdfexport' -> Grid component id + _ + toolbar item name
this.$refs.grid.pdfExport();
}
}
}
methods: {
toolbarClick: function(args) {
//debugger;
if (args.item.id === "Grid_excelexport") {
// 'Grid_excelexport' -> Grid component id + _ + toolbar item name
this.$refs.grid.excelExport();
}
if (args.item.id === "Grid_pdfexport") {
// 'Grid_pdfexport' -> Grid component id + _ + toolbar item name
this.$refs.grid.pdfExport();
}
}
} |
|
App.vue
toolbarClick: function(args) {
if (args.item.text === "Excel Export") {
args.cancel = true; // prevent default exporting
let state1 = {
skip: 0,
take: this.$refs.grid.$el.ej2_instances[0].pageSettings
.totalRecordsCount
};
this.orderService.execute(state1).then(gridData => {
debugger; // get all records from service
let excelExportProperties = {
dataSource: gridData.result, // assign result to data source property
fileName: "new.xlsx"
};
this.$refs.grid.excelExport(excelExportProperties); // Export all page records
});
}
} |
|
App.vue
<ejs-grid ref="grid" :dataSource='data' height="400" width="800" :frozenColumns="2" :enableVirtualization="true"
:actionFailure="actionFailure" :toolbarClick="toolbarClick" :dataStateChange='dataStateChange' >
<e-columns>
<e-column field= "OrderID" headerText="Order ID" width="130" textAlign='Right' ></e-column>
<e-column field= "CustomerID" headerText="CustomerID" width="130" textAlign='Right' ></e-column>
<e-column field= "Freight" headerText="Freight" width="130" textAlign='Right' ></e-column>
<e-column field= "ShipCountry" headerText="Country" width="130" textAlign='Right' ></e-column>
<e-column field= "ShipCity" headerText="City" width="130" textAlign='Right' ></e-column>
<e-column field= "ShipAddress" headerText="Address" width="130" textAlign='Right' ></e-column>
</e-columns>
</ejs-grid>
dataStateChange: function (state) {
if (state.action && (state.action.requestType === "filterchoicerequest" || state.action.requestType ==="filtersearchbegin")) {
this.orderService.execute(state).then((e) => {
state.dataSource(e.result);
});
} else {
this.orderService.execute(state).then(( gridData ) => this.data = gridData );
}
|