How to use the dash-table/utils/actions.getAffectedColumns function in dash-table

To help you get started, we’ve selected a few dash-table examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plotly / dash-table / src / dash-table / derived / header / content.tsx View on Github external
function selectColumn(current_selection: string[], column: IColumn, columns: Columns, columnRowIndex: any, setProps: SetProps, mergeDuplicateHeaders: boolean, clearSelection: boolean, select: boolean) {
    // if 'single' and trying to click selected radio -> do nothing
    if (clearSelection && !select) {
        return () => { };
    }

    let selected_columns = actions.getAffectedColumns(column, columns, columnRowIndex, mergeDuplicateHeaders, true);

    if (clearSelection) {
        return () => setProps({ selected_columns });
    } else if (select) {
        // 'multi' + select -> add to selection (union)
        return () => setProps({
            selected_columns: R.union(current_selection, selected_columns)
        });
    } else {
        // 'multi' + unselect -> invert of intersection
        return () => setProps({
            selected_columns: R.without(selected_columns, current_selection)
        });
    }
}
github plotly / dash-table / src / dash-table / derived / header / content.tsx View on Github external
) => () => {
    const props = action(column, columns, visibleColumns, columnRowIndex, mergeDuplicateHeaders, data);

    const affectedColumIds = actions.getAffectedColumns(column, columns, columnRowIndex, mergeDuplicateHeaders);

    if (action === actions.deleteColumn) {
        if (R.intersection(selected_columns, affectedColumIds).length > 0) {
            props.selected_columns = R.without(
                affectedColumIds,
                selected_columns
            );
        }
    }
    setProps(props);

    const affectedColumns: Columns = [];
    R.forEach(id => {
        const affectedColumn = columns.find(c => c.id === id);
        if (affectedColumn) {
            affectedColumns.push(affectedColumn);
github plotly / dash-table / src / dash-table / derived / header / content.tsx View on Github external
if (columnIndex === R.last(indices)) {
                            colSpan = labels.length - columnIndex;
                        } else {
                            colSpan = indices[index + 1] - columnIndex;
                        }
                    }

                    const clearable = paginationMode !== TableAction.Custom && getColumnFlag(headerRowIndex, lastRow, column.clearable);
                    const deletable = paginationMode !== TableAction.Custom && getColumnFlag(headerRowIndex, lastRow, column.deletable);
                    const hideable = getColumnFlag(headerRowIndex, lastRow, column.hideable);
                    const renamable = getColumnFlag(headerRowIndex, lastRow, column.renamable);
                    const selectable = getColumnFlag(headerRowIndex, lastRow, column.selectable);

                    const spansAllColumns = visibleColumns.length === colSpan;

                    const affectedColumns = actions.getAffectedColumns(
                        column,
                        columns,
                        headerRowIndex,
                        mergeDuplicateHeaders,
                        true
                    );
                    const allSelected =
                        selectable &&
                        (
                            column_selectable !== 'single' ||
                            (selected_columns.length === affectedColumns.length)
                        ) &&
                        R.all(
                            c => selected_columns.indexOf(c) !== -1,
                            affectedColumns
                        );