admin 管理员组

文章数量: 1086019

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.

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)