How select row with no children?
Hi all. Please tell me.
The table is selectable and expandable. How to use row.getToggleRowSelectedProps().onChange or row.toggleRowSelected() and at the same time select only the parent line without the children?
1 Reply
wise-whiteOP•3y ago
...
initialState,
stateReducer: (newState, action) => {
if (action.type === 'toggleRowSelected' && action.value === true) {
const hashTable = Object.create(null);
Object.keys(newState.selectedRowIds).forEach((item) => {
if (!importData.falseChilds?.includes(item)) {
hashTable[item] = true;
}
});
newState.selectedRowIds = hashTable;
}
return newState;
},
},
useExpanded,
useRowSelect
...
If anyone needs it, I can describe the implementation in more detail.