Jan 20, 2025
0
Level 1
How to use AG Grid in Nova 4?
Hi. I'm trying to run AG Grid (Vue 3 version) inside a Laravel Nova tool (php artisan nova:tool).
I'm able to run a new tool, it renders a custom Vue 3 component but when I try to render AG Grid with <ag-grid-vue>...</ag-grid-vue> I get this error:
nova.js:183 TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_0__.useTemplateRef) is not a function
183 line in nova.js is this.app.mount(this.mountTo)
I wonder what can I try to do to fix this?
Laravel Nova 4 uses Vue 3 and AG Grid uses Vue 3 too.
My code is just an example from AG Grid website https://www.ag-grid.com/vue-data-grid/getting-started/
<script>
import { AllCommunityModule, ModuleRegistry } from 'ag-grid-community';
import { ref } from 'vue';
import { AgGridVue } from "ag-grid-vue3";
ModuleRegistry.registerModules([AllCommunityModule]);
function setup() {
const rowData = ref([
{ make: "Tesla", model: "Model Y", price: 64950, electric: true },
{ make: "Ford", model: "F-Series", price: 33850, electric: false },
{ make: "Toyota", model: "Corolla", price: 29600, electric: false },
]);
const colDefs = ref([
{ field: "make" },
{ field: "model" },
{ field: "price" },
{ field: "electric" }
]);
return {
rowData,
colDefs,
};
}
export default {
name: "App",
components: {
AgGridVue,
},
setup() {},
};
</script>
<template>
<ag-grid-vue
:rowData="rowData"
:columnDefs="colDefs"
style="height: 500px"
>
</ag-grid-vue>
</template>
Please or to participate in this conversation.