Setting Column Template on Auto Generated Column
Hi Syncfusion,
Is it possible to set column template on auto generated column based on some condition of the data in that column?
It says here you can set some options to auto generated columns on dataBound event;
But it is unclear if column template could be set at on the dataBound event.
Thanks,
Marius
SIGN IN To post a reply.
3 Replies
SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
December 16, 2019 09:55 AM UTC
Hi Marius,
Thanks for contacting Syncfusion support,
As per your requirement, we have used dataBound event and load event of the Grid. Assigned the compiled template to the required column in the dataBound event of the Grid. Refer to the following code example.
|
<template>
<div id="app">
<ejs-grid
ref="gridObj"
:dataSource="data"
height="300px"
allowPaging="true"
:dataBound="dataBound"
:load="onLoad"
></ejs-grid>
</div>
</template>
let cTemp = function() {
return {
template: Vue.component("columnTemplate", {
template: `<a rel='nofollow' href="#">{{CustomerID}}</a>`,
data: function() {
return {
data: {}
};
},
computed: {
CustomerID: function() {
return this.data.CustomerID;
}
}
})
};
};
export default {
data() {
return {
data: orderDetails.slice(0),
isInitial: false
};
},
methods: {
dataBound: function() {
var gridObj = document.getElementsByClassName("e-grid")[0]
.ej2_instances[0];
let tempCol = gridObj.getColumnByField("CustomerID");
tempCol.template = cTemp;
tempCol.templateFn = templateCompiler(cTemp);
if (this.isInitial) {
gridObj.refreshColumns();
this.isInitial = false;
}
},
onLoad: function() {
this.isInitial = true;
}
},
|
Sample link: https://codesandbox.io/s/vue-template-3n4sv
Regards,
Seeni Sakthi Kumar S
ML
Marius Lian
December 16, 2019 12:27 PM UTC
Great! Thanks.
PS
Pavithra Subramaniyam
Syncfusion Team
December 17, 2019 05:03 AM UTC
Hi Marius,
Thanks for your update.
Please contact us if you need any further assistance on this. As always, we will be happy to assist you.
Regards,
Pavithra S.
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
ML Marius Lian
- Dec 13, 2019 11:35 AM UTC
- Dec 17, 2019 05:03 AM UTC