Hi,
I want to provide column / filter / edit templates to grid / treegrid component. I want to do so using vue single file components.
Some questions about templates using vue SFC:
Question 1: How can I pass a data to the vue component template?
After debug:
myTemplate: () => {
return {
template: {
extends: app.component("template", MyTemplateComp),
propsData: {
message: “My message”
}
}
}
}
Comment 1: When defining the template in a single file component, in vue 3 I also need to register this component as a global component (otherwise it is not working) as below:
import { createApp } from ‘vue’
import MyTemplateComp from './MyTemplateComp.vue'
const app = createApp()
export default {
data() {
return {
myTemplate: () => { return {template: app.component("myTemplate ", MyTemplateComp)}}
}
}
}
It is missing in the
documentation for vue 3 (see this link).
Comment 2: The component name must be the same as the template function name, otherwise it won’t work.
Working:
myTemplate: () => { return { template: app.component("myTemplate", MyTemplateComp)}}
Not working:
myTemplate: () => { return { template: app.component("columnTemplate", MyTemplateComp)}}