mirror of
https://github.com/rowyio/rowy.git
synced 2026-02-24 20:20:05 +01:00
Merge pull request #53 from AntlerVC/develop
feat: new rows created with filter data as initial value
This commit is contained in:
@@ -14,7 +14,6 @@ const Grid = (props: any) => {
|
||||
columns,
|
||||
RowRenderer,
|
||||
handleRowGetter,
|
||||
|
||||
tableHeight,
|
||||
onGridRowsUpdated,
|
||||
rows,
|
||||
|
||||
@@ -221,7 +221,7 @@ function Table(props: Props) {
|
||||
return (
|
||||
<Button
|
||||
onClick={() => {
|
||||
tableActions.row.add();
|
||||
addRow();
|
||||
}}
|
||||
>
|
||||
Add a new row
|
||||
@@ -241,6 +241,19 @@ function Table(props: Props) {
|
||||
}
|
||||
return rows[index];
|
||||
};
|
||||
const addRow = (data?: any) => {
|
||||
if (filters) {
|
||||
// adds filter data into the new row
|
||||
const filtersData = filters.reduce(
|
||||
(accumulator: any, currentValue: FireTableFilter) => ({
|
||||
...accumulator,
|
||||
[currentValue.key]: currentValue.value,
|
||||
}),
|
||||
{}
|
||||
);
|
||||
tableActions.row.add({ ...filtersData, ...data });
|
||||
} else tableActions.row.add({ ...data });
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<Suspense fallback={<div>Loading header...</div>}>
|
||||
@@ -251,7 +264,7 @@ function Table(props: Props) {
|
||||
updateConfig={tableActions.table.updateConfig}
|
||||
columns={columns}
|
||||
filters={filters}
|
||||
addRow={tableActions.row.add}
|
||||
addRow={addRow}
|
||||
/>
|
||||
</Suspense>{" "}
|
||||
{!tableState.loadingColumns ? (
|
||||
@@ -267,7 +280,7 @@ function Table(props: Props) {
|
||||
rows={rows}
|
||||
resizeColumn={tableActions.column.resize}
|
||||
loadingRows={tableState.loadingRows}
|
||||
addRow={tableActions.row.add}
|
||||
addRow={addRow}
|
||||
setSelectedCell={setSelectedCell}
|
||||
/>
|
||||
) : (
|
||||
|
||||
@@ -16,7 +16,7 @@ export default function TableView() {
|
||||
// encoded
|
||||
//%5B%7B%20key:%20%22cohort%22,%20operator:%20%22==%22,%20value:%20%22SYD1%22%20%7D%5D
|
||||
// decoded
|
||||
//[{ key: "cohort", operator: "==", value: "AMS1" }]
|
||||
//[{key:"cohort",operator:"==",value:"AMS1"}]
|
||||
console.log(parsed.filters);
|
||||
filters = eval(parsed.filters);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user