简体   繁体   English

React Ag-网格显示

[英]React Ag-grid displaying

When I add simple table on my page:当我在页面上添加简单表格时:


...

    const [columnDefs] = useState([
        { headerName: "id", field: "id" },
        { headerName: "name", field: "name" },
        { headerName: "type", field: "type" },
    ]);

    const defaultColDef = useMemo(() => {
        return {
            flex: 1,
            minWidth: 140,
            resizable: true,
        };
    }, []);


    return (
        <>
            <div className="ag-theme-alpine" style={{ height: 400, width: 500 }}>
                <AgGridReact 
                    rowData={foundTemplates} 
                    columnDefs={columnDefs} 
                    getRowId={getRowId} 
                    defaultColDef={defaultColDef}></AgGridReact>
                    pagination={false}
            </div>
        </>
    );

foundTemplates has the following structure: foundTemplates 具有以下结构:

        { id: 1, name: "testName1", type: "TestRFQ", description: "description1", ownerCurrentUser: true, lastUsed: true },
        { id: 2, name: "testName2", type: "TestRFI", description: "description2", ownerCurrentUser: false, lastUsed: true },
        { id: 3, name: "testName3", type: "TestAuction", description: "description3", ownerCurrentUser: true, lastUsed: false },
        { id: 4, name: "testName4", type: "TestAuction", description: "description4", ownerCurrentUser: false, lastUsed: false },

I have a problem with displaying data in the right way: all data is displaying in one column (despite I have some kind of column definitions with 3 fields at least).我在以正确的方式显示数据时遇到问题:所有数据都显示在一列中(尽管我有某种至少包含 3 个字段的列定义)。 Also I've tried to remove a pagination block ( pagination={false} ), but it is still displaying.我也尝试删除分页块( pagination={false} ),但它仍在显示。 How it looks now现在的样子

In general I'm planning to use custom cell renderer for info displaying, but now I can't even display a simple data.一般来说,我打算使用自定义单元格渲染器来显示信息,但现在我什至无法显示简单的数据。

The root cause: I didn't import ag-grid css.根本原因:我没有导入ag-grid css。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM