Row height in Vue Grid component
28 Mar 20234 minutes to read
You can customize the row height of grid rows through the rowHeight
property. The rowHeight
property is used to change the row height of entire grid rows.
In the below example, the rowHeight
is set as ‘60px’.
<template>
<div id="app">
<ejs-grid :dataSource="data" :enableHover='false' :allowSelection='false' height='295' rowHeight=60>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
<e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90></e-column>
<e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' type='date' width=120> </e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin } from "@syncfusion/ej2-vue-grids";
import { data } from './datasource.js';
Vue.use(GridPlugin);
export default {
data() {
return {
data: data
};
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";
</style>
Customize row height for particular row
Grid row height for particular row can be customized using the rowDataBound
event by setting the rowHeight
in arguments for each row based on the requirement.
In the below example, the row height for the row with OrderID as ‘10249’ is set as ‘90px’ using the rowDataBound
event.
<template>
<div id="app">
<ejs-grid :dataSource="data" height='315' :rowDataBound='rowDataBound'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
<e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90></e-column>
<e-column field='OrderDate' headerText='Order Date' textAlign='Right' format='yMd' type='date' width=120 > </e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import Vue from "vue";
import { GridPlugin } from "@syncfusion/ej2-vue-grids";
import { data } from './datasource.js';
Vue.use(GridPlugin);
export default {
data() {
return {
data: data
};
},
methods: {
rowDataBound: (args) {
if (args.data['OrderID'] === 10249) {
args.rowHeight = 90;
}
}
}
});
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css";
</style>
In virtual scrolling mode, it is not applicable to set the
rowHeight
using therowDataBound
event.