<template>
<div id="app">
<Button type="button" @click="selectCell">BindData</Button>
<ejs-grid id="Grid" ref="grid" :dataSource="data" :allowPaging="true" :toolbar="toolbar">
<e-columns>
<e-column field="degreeEntry" headerText="degreeEntry" width="90" isPrimaryKey="true"></e-column>
<e-column field="txtCity" headerText="txtCity" width="120"></e-column>
<e-column field="txtState" headerText="txtState" width="120"></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin, Edit, Page, Toolbar } from "@syncfusion/ej2-vue-grids";
Vue.use(GridPlugin);
export default {
data() {
return {
data: [{ }],
toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"]
};
},
methods: {
selectCell() { //button click event
this.$refs.grid.dataSource = [{ "degreeEntry": "degree", "txtCity": "Berkeley",
"txtState": "CA" }, { "degreeEntry": "training", "txtCity": "Berkeley",
"txtState": "CA" }];
}
},
provide: {
grid: [Page, Edit, Toolbar]
}
};
</script>
<style>
@import "https://cdn.syncfusion.com/ej2/material.css";
</style>
|
<template>
<div id="app">
<Button type="button" @click="selectCell">BindData</Button>
<ejs-grid id="Grid" ref="grid" :dataSource="data" :allowPaging="true" :toolbar="toolbar">
</ejs-grid>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin, Edit, Page, Toolbar } from "@syncfusion/ej2-vue-grids";
Vue.use(GridPlugin);
export default {
data() {
return {
data: [{ }],
toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"]
};
},
methods: {
selectCell() { //button click event
this.$refs.grid.dataSource = [
{
"experienceFrom": "1995",
"experienceOrganization": "American+Psychological+Association",
"PositionTitle": "Member+",
"add-experience-modal-recid": "241"
},
{
"experienceFrom": "Memberships",
"experienceOrganization": "Executive+Committee%2C+American+Society+of+Preventive+Oncology%3B+NCI+Cancer+Prevention+Scientific+Education+Committee%3B+Screening+%26+Prevention+Editorial+Board%2C+NCI+Physicians+Data+Query%3B+Executive+Board%2C+South+Carolina+Tobacco+Collaborative%3B+South+Carolina+Cancer+Control+Advisory+Committee%3B+South+Carolina+Cancer+Alliance+Coordinating+Council%3B+Institute+of+Medicine+Committee+on+the+Health+Implications+of+Raising+the+Minimum+Age+for+Purchasing+Tobacco+Products",
"PositionTitle": "",
"add-experience-modal-recid": "350"
},
{
"experienceFrom": "2008",
"experienceOrganization": "American+Geriatrics+Society",
"PositionTitle": "Member",
"add-experience-modal-recid": "237"
}
];
}
},
provide: {
grid: [Page, Edit, Toolbar]
}
};
</script>
<style>
@import "https://cdn.syncfusion.com/ej2/material.css";
</style>
|
Thank you so much! You helped me a lot too.
Hi-- Is there a way to set the minimum column width from the automatically generated columns ? It seems that it is forced into the area that was originally created. It would be great if they were larger and had an automatic horizonal scroll. Is that possible?
Update:-- Got it working Added resize
https://ej2.syncfusion.com/vue/documentation/grid/columns/auto-fit-columns/
Willaim,
If you are using auto generated columns, you can set column options such as format, width to the auto generated columns by using dataBound event of the grid. After setting the width in the columns you have call refreshColumn() method for UI changes. Please refer the below documentation for more information.
Documentation: https://ej2.syncfusion.com/angular/documentation/grid/columns/auto-generated-columns/#set-column-options-to-auto-generated-columns