admin管理员组

文章数量:1394601

I have this Material-UI DataGrid, how can I sum all of the values for the column Total Amount in which this will also be updated once filter is triggerd as well?

I am really unsure on how I can sum the entire column of total amount. Any help would be appreciated. Thank you

Codes:

  const [filterModel, setFilterModel] = React.useState({
    items: [
      {
        columnField: "totalAmount",
        operatorValue: ">",
        value: "200"
      }
    ]
  });

  return (
    <div style={{ height: 400, width: "100%" }}>
      <DataGrid
        // rows={rows}
        columns={columns}
        rows={data}
        ponents={{
          Toolbar: GridToolbar
        }}
        filterModel={filterModel}
        onFilterModelChange={(newFilterModel) => setFilterModel(newFilterModel)}
      />
    </div>
  );
}

I have this Material-UI DataGrid, how can I sum all of the values for the column Total Amount in which this will also be updated once filter is triggerd as well?

I am really unsure on how I can sum the entire column of total amount. Any help would be appreciated. Thank you

Codes:

  const [filterModel, setFilterModel] = React.useState({
    items: [
      {
        columnField: "totalAmount",
        operatorValue: ">",
        value: "200"
      }
    ]
  });

  return (
    <div style={{ height: 400, width: "100%" }}>
      <DataGrid
        // rows={rows}
        columns={columns}
        rows={data}
        ponents={{
          Toolbar: GridToolbar
        }}
        filterModel={filterModel}
        onFilterModelChange={(newFilterModel) => setFilterModel(newFilterModel)}
      />
    </div>
  );
}
Share Improve this question edited May 3, 2022 at 13:59 JS3 asked Mar 13, 2022 at 7:15 JS3JS3 1,8694 gold badges34 silver badges83 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You can create custom footer ponent, and then pass total value as a prop.

Here I created sandbox with plete solution.

本文标签: