<template>
<div id="app">
<ejs-grid
id="Grid"
ref="grid"
:rowDataBound="rowDataBound"
:dataSource="data"
:allowPaging="true"
>
<e-columns>
// if you have the rowheader value in dataSource then you can set by adding <span>${fieldName}</span>
<e-column width="80" headerText="S.NO" template="<span></span"></e-column>
<e-column field="OrderID" headerText="Order ID" width="90"></e-column>
<e-column field="Freight" headerText="Freight" format="C2" width="90"></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
. . .
methods: {
rowDataBound: function(e) {
var data = this.$refs.grid.ej2Instances.getRowObjectFromUID(
e.row.getAttribute("data-uid"); // getting the row details
);
e.row.getElementsByTagName("span")[0].innerText = data.index;
}
}
};
</script>
|
<ejs-grid
:queryCellInfo="queryCellInfo"
:dataSource="data"
:frozenRows="rows"
:frozenColumns="columns"
. . . >
<e-columns>
<e-column width="80" headerText="S.NO" template="<span></span"></e-column>
. . .
</e-columns>
</ejs-grid>
export default {
data() {
return {
data: data,
rows: 2,
columns: 1
};
},
provide: {
grid: [Page, Freeze]
},
methods: {
queryCellInfo: function(e) {
if (e.column.headerText === "S.NO")
e.cell.getElementsByTagName("span")[0].innerText = e.cell.getAttribute(
"index"
);
}
|