I have this React code which I would like to use to select all rows:
export interface ILiquidationSpread {
id?: number;
}
export const getEntitiesIds: ICrudGetAllLiquidationSpreadIdsParamsAction<[]> = (
searchIdParam,
.....
) => {
const requestUrl = `${apiUrl}/rows-id-list?`;
return {
type: ACTION_TYPES.FETCH_LIQUIDATIONSPREAD_IDS_LIST,
payload: axios.get<[]>(`${requestUrl}......),
};
};
from this call I get the following response:
[151, 4, 11, 28, 35, 1, 2, 29, 3, 7, 496, 19, 68, 9, 166, 12, 8, 167, 67, 6, 168, 30, 112, 10, 958,…]
Using this code I would like to select all rows into paginated table:
const selectAll = event => {
const entitiesIds = props.getEntitiesIds(
........
);
// how I can get the ids as a list and select all table rows?
let x = [];
const checked = event.target.checked;
const cbs: NodeListOf<HTMLInputElement> = document.querySelectorAll('.liquidationSpreadCb');
cbs.forEach((cb: HTMLInputElement, i) => {
cb.click();
const itemId = cb.className.replace(/D/g, '');
const item: ILiquidationSpread = liquidationSpreadList.filter(val => val.id === Number(itemId))[0];
x.push(item);
});
if (!checked) {
x = [];
}
setSelectedItems(x);
};
How I can get a list of all Ids at the beginning of the rows and select all table rows?