Can I use ag-grid-community library with LitElements?
P粉553428780
P粉553428780 2023-08-14 12:57:26
0
1
409
<p>Is it possible to use ag-grid-community with LitElements? This is what I have tried but cannot initialize the ag-grid instance using the code below. </p> <p>Console Error - ag-grid-community.auto.esm.js:45056 Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'. </p> <pre class="brush:php;toolbar:false;">import { Grid } from 'ag-grid-community'; export class myComponent extends LitElement { static scopedElements = { 'ag-grid': Grid }; constructor() { super(); this.columnDefs = [ {headerName: "Make", field: "make"}, {headerName: "Model", field: "model"}, {headerName: "Price", field: "price"} ]; this.rowData = [ {make: "Toyota", model: "Celica", price: 35000}, {make: "Ford", model: "Mondeo", price: 32000}, {make: "Porsche", model: "Boxter", price: 72000} ]; this.gridOptions = { columnDefs: this.columnDefs, rowData: this.rowData, }; const eGridDiv = document.querySelector('#myGrid'); new Grid(eGridDiv, this.gridOptions); } render() { return html` <div> <ag-grid .gridOptions=${this.gridOptions} ></ag-grid> </div> `; } }</pre>
P粉553428780
P粉553428780

reply all(1)
P粉893457026

You must remove the comment text from the code

**指定数据** this.rowData = [    

**让网格知道要使用哪些列和数据** this.gridOptions

Also, I think you forgot to remove the comma here:

.gridOptions=${this.gridOptions}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!