可以将ag-grid-community与LitElements一起使用吗?

问题描述 投票:0回答:1

我在使用点亮元素初始化网格实例时遇到困难,

这是我尝试过的示例,

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"}
    ];

specify the data this.rowData = [
      {make: "Toyota", model: "Celica", price: 35000},
      {make: "Ford", model: "Mondeo", price: 32000},
      {make: "Porsche", model: "Boxter", price: 72000}
    ];

let the grid know which columns and what data to use 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>
      </div>
    `;   } }
javascript ag-grid web-component lit-element
1个回答
0
投票

您必须从代码中删除注释文本

 **specify the data** this.rowData = [    

**let the grid know which columns and what data to use** this.gridOptions

我还认为你忘记在这里删除逗号:

.gridOptions=${this.gridOptions}
© www.soinside.com 2019 - 2024. All rights reserved.