How to Bulk Edit Data With React Query Builder
Using React Query Builder for a completely different purpose
Now we're going to use a query builder for a different purpose: bulk editing. This is useful when your data grid is updateable and you want to be able to define many changes at once.
Grid configuration#
First we'll add a selection column to the data grid so users can determine exactly which rows they want to update. Make sure to set the rowSelection
prop to "multiple"
so we can select multiple rows. We'll also need to capture the grid API in a state variable for later use.
xxxxxxxxxx
import { ColDef, GridApi } from "ag-grid-community";
xxxxxxxxxx
const [gridApi, setGridApi] = useState<GridApi>();
xxxxxxxxxx
<AgGridReact
columnDefs={[
{
field: "selectionColumn",
headerCheckboxSelection: true,
checkboxSelection: true,
width: 40,
},
dataset === "sales" ? columnDefs : columnDefsUNL), (
]}
onGridReady={(gre) => setGridApi(gre.api)}
rowData={dataset === "sales" ? rawData : rawDataUNL}
rowSelection="multiple"
suppressPropertyNamesCheck
/>
Query builder configuration#
This lesson preview is part of the Building Advanced Admin Reporting in React course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.
Get unlimited access to Building Advanced Admin Reporting in React, plus 70+ \newline books, guides and courses with the \newline Pro subscription.
