Hi,
I would like some help regarding Template and Dynamic Columns. So let's say first, dynamic columns are working fine (vue3, and ej2-vue-grid latest versions loaded before this article) until "you try to implement template" which is not defined in the same file (as in your example)
Your grid also put in separate component, which accepts prop columns, but let's simplify it.
So, what do I have:
above, there is:
and in methods
So when I debug your code, which takes some time but :)
templateCompRef = object.template._context.components[templateElement.name];
So we do have here, list of components in
object.template._context.components
as {{linkTemplate: {...}}} => this is all fine, but
templateElement.name is not set to "linkTemplate" but to string "bound linkTemplate" - which obviously returns nothing and everything "dies".
The grid (does not display an error in rendering), there is no errors in console - nothing. Grid says "No records to display" - which is not true. And it also say "1 of 1 pages (2 items)" which is in contradiction with last statement.
Any help would be nice?
BR,
Vedran
Replying to myself if anyone get in this situation, but I'm still thinking this is a bug :)
If we put definition of "linkTemplate" to data as function:
and we put columns definition in computed property (which is misuse of vue computed props)
Then your component is working by your design.
|
[ColumnTemp.vue]
<template>
<div id="dialogTemplate1"> {{data.OrderID}} - {{data.CustomerID}}
</div>
</template>
<script>
export default {
name: "dialogTemplate1",
data() {
return {
};
},
};
</script>
|
|
[App.vue]
<template>
<div id="app">
<ejs-grid :dataSource='data' :allowPaging="true" :actionFailure="actionFailure">
<e-columns>
<e-column field='CustomerID' width='125' textAlign='Right'></e-column>
<e-column field='OrderID' width='125' textAlign='Right'></e-column>
<e-column field='ShipCountry' width='125' textAlign='Right'></e-column>
<e-column headerText='Employee Image' width='150' textAlign='Center' :template="colTemplate"></e-column>
</e-columns>
</ejs-grid>
</div>
</template>
<script>
import { GridComponent, ColumnsDirective, ColumnDirective, Page } from '@syncfusion/ej2-vue-grids';
import dialogTemplate1 from "./ColumnTemp.vue";
import { createApp } from "vue";
const app = createApp();
// Template declaration
var colVue = app.component("colTemplate", dialogTemplate1);
export default {
name: 'App',
components: {
'ejs-grid' : GridComponent,
'e-columns' : ColumnsDirective,
'e-column' : ColumnDirective,
},
data() {
return {
data: [
{
"OrderID":10248,
"CustomerID":"VINET",
"ShipCountry":"France"
},
{
"OrderID":10249,
"CustomerID":"TOMSP",
"ShipCountry":"Germany"
}],
colTemplate: function () {
return { template: colVue};
},
};
},
// module injection
provide: {
grid: [Page],
}
};
</script>
|