Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The columns in different datatable will be mixed after reorder columns in one datatable #2558

Closed
christinJiang opened this issue Jan 4, 2022 · 1 comment

Comments

@christinJiang
Copy link

I use prime react datatable in my project, three menu items "当天检查", "门诊His", "急诊His" have different columns. I switch in 3 items, the different table columns will be switched. But if I reorder table columns in item "门诊His", and switch to item "急诊His", the table columns' order will be showed same as last item "门诊His". This behavior is wrong.

The reason is that in file https://github.com/primefaces/primereact/blob/master/components/lib/datatable/DataTable.js
getColumns(ignoreReorderable) {
if (!ignoreReorderable && this.props.reorderableColumns && this.state.columnOrder) {
let orderedColumns = this.state.columnOrder.reduce((arr, columnKey) => {
const column = this.findColumnByKey(columns, columnKey);
column && arr.push(column);
return arr;
}, []);

        return [...orderedColumns, ...columns.filter(col => orderedColumns.indexOf(col) < 0)];
    }

    return columns;

}

The param "this.state.columnOrder" in different datatables are same, this is wrong.
This param in item "急诊His" datatable should be undefined, but not detail value.

today
his1
his2

I use below temporary solution to fix above issue.
#1088

@yigitfindikli
Copy link
Contributor

Issue is not clear, please feel free to reopen with a codesandbox example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants