【问题标题】:DataGrid Material UI getRowClassName not working on TypescriptDataGrid Material UI getRowClassName 在 Typescript 上不起作用
【发布时间】:2021-06-28 18:36:04
【问题描述】:

我正在尝试根据DataGrid 组件中每一行的值添加一个类。但是,当我尝试在组件上使用 getRowClassName 时,我收到以下错误表单 TypeScript

    Type '{ rows: any[]; getRowClassName: (params: any) => string; columns: GridColDef[]; pagination: true; page: number; error: ApolloError; pageSize: number; hideFooterPagination: boolean; ... 6 more ...; componentsProps: { ...; }; }' is not assignable to type 'IntrinsicAttributes & Omit<GridComponentProps, "disableMultipleSelection" | "disableMultipleColumnsFiltering" | "disableMultipleColumnsSorting" | ... 5 more ... | "options"> & { ...; } & RefAttributes<...>'.
      Property 'getRowClassName' does not exist on type 'IntrinsicAttributes & Omit<GridComponentProps, "disableMultipleSelection" | "disableMultipleColumnsFiltering" | "disableMultipleColumnsSorting" | ... 5 more ... | "options"> & { ...; } & RefAttributes<...>'.

我正在使用这样的功能:

<DataGrid
    rows={rows}
    getRowClassName={(params) => (
        `my-datagrid-theme--custom-${params.getValue(params.row.something, 'false')}`
    )}
    columns={columns}
    pagination
    page={page}
    error={error}
    paginationMode="server"
    onPageChange={handlePageChange}
    loading={loading}
/>

我该如何解决这个问题?

【问题讨论】:

  • 你使用什么版本的@material-ui/data-grid

标签: reactjs typescript datagrid material-ui


【解决方案1】:

您必须升级到最新版本才能解决此问题

【讨论】:

    猜你喜欢
    • 2021-08-12
    • 2015-09-26
    • 1970-01-01
    • 2020-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-09
    • 2020-07-09
    相关资源
    最近更新 更多