Executes grid actions and row actions.

  • Type Parameters

    • Data extends unknown = any

      The type of data in the grid rows.

    Parameters

    • Object: IParams<Data>

      The parameters for the useGridAction function.

      • onLoadStart

        A callback function executed when a grid action or row action is started.

      • onLoadEnd

        A callback function executed when a grid action or row action is completed or failed.

      • throwError

        A flag indicating whether to throw an error if a grid action or row action fails.

      • fallback

        A flag indicating whether to use a fallback solution if a grid action or row action fails.

      • fetchRow

        A function that fetches a row.

      • onAction

        A callback function executed when a grid action is performed. This function receives the action name, the rows to perform the action on, and a deselectAll function to deselect all rows.

      • onRowAction

        A callback function executed when a row action is performed. This function receives the action name, the row to perform the action on, and a deselectAll function to deselect all rows.

    Returns {
        commitAction: (p?: string) => Promise<null | void>;
        commitRowAction: (action: string, row: Data) => Promise<null | void>;
        deselectAll: () => void;
        gridProps: {
            onSelectedRows: (rowIds: string[]) => void;
            selectedRows: string[];
        };
        selectedRows: string[];
    }

    An object containing the following properties:

    • deselectAll - A function that deselects all rows in the grid.
    • selectedRows - An array of selected rows in the grid.
    • gridProps - The grid properties.
    • commitAction - A function that commits a grid action. This function receives the action name and calls the onAction callback function with the selected rows.
    • commitRowAction - A function that commits a row action. This function receives the action name and the row and calls the onRowAction callback function.