T
TanStack3y ago
other-emerald

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
other-emerald
other-emeraldOP3y 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.

Did you find this page helpful?