MCPcopy Create free account
hub / github.com/TanStack/table / mutateRowIsSelected

Function mutateRowIsSelected

packages/table-core/src/features/RowSelection.ts:551–589  ·  view source on GitHub ↗
(
  selectedRowIds: Record<string, boolean>,
  id: string,
  value: boolean,
  includeChildren: boolean,
  table: Table<TData>,
)

Source from the content-addressed store, hash-verified

549}
550
551const mutateRowIsSelected = <TData extends RowData>(
552 selectedRowIds: Record<string, boolean>,
553 id: string,
554 value: boolean,
555 includeChildren: boolean,
556 table: Table<TData>,
557) => {
558 const row = table.getRow(id, true)
559
560 // const isGrouped = row.getIsGrouped()
561
562 // if ( // TODO: enforce grouping row selection rules
563 // !isGrouped ||
564 // (isGrouped && table.options.enableGroupingRowSelection)
565 // ) {
566 if (value) {
567 if (!row.getCanMultiSelect()) {
568 Object.keys(selectedRowIds).forEach((key) => delete selectedRowIds[key])
569 }
570 if (row.getCanSelect()) {
571 selectedRowIds[id] = true
572 }
573 } else {
574 delete selectedRowIds[id]
575 }
576 // }
577
578 if (includeChildren && row.subRows?.length && row.getCanSelectSubRows()) {
579 row.subRows.forEach((row) =>
580 mutateRowIsSelected(
581 selectedRowIds,
582 row.id,
583 value,
584 includeChildren,
585 table,
586 ),
587 )
588 }
589}
590
591export function selectRowsFn<TData extends RowData>(
592 table: Table<TData>,

Callers 1

RowSelection.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected