btnClick: function(event) {
var grid = this.$refs.grid.ej2Instances;
grid.dataSource = customerData; // Changed the Grid datasource
grid.columns = [// changed the Grid columns
{
field: "CustomerID",
headerText: "Customer ID",
width: 120
},
{
field: "CompanyName",
headerText: "Company Name",
width: 120
},
{
field: "ContactName",
headerText: "Contact Name",
width: 120
}
];
} |
<template>
<div id="app">
<ejs-grid :dataSource="data" height="315">
<e-columns>
. . .
<e-column field="Freight" headerText="Freight" textAlign="Right" :valueAccessor="currencyFormatter" width="80"></e-column>
<e-column field="ShipCity" headerText="Ship City" width="130" :valueAccessor="valueAccess"></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
export default {
. . .
methods: {
currencyFormatter: function(field, data, column) {
return "€" + data["Freight"];
},
valueAccess: function(field, data, column) {
return data[field] + "-" + data["ShipRegion"];
}
}
};
</script> |
btnClick: function(event) {
var grid = this.$refs.grid.ej2Instances;
grid.columns = [
{
field: "CompanyName",
headerText: "Company Name",
width: 160,
valueAccessor:function(field, data, column) {
return "Accessed " + data["CompanyName"];
}
},
. . .
];
}
}
}; |
var grid = this.$refs.grid.ej2Instances;
console.log(grid.getPrimaryKeyFieldNames()); |
{
field: "Quantity",
headerText: "Quantity",
format: 'N2',
type: 'number',
width: 120
} |