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

Add columnOrder as a property instead of state only #810

Closed
Bublade opened this issue Mar 13, 2019 · 1 comment
Closed

Add columnOrder as a property instead of state only #810

Bublade opened this issue Mar 13, 2019 · 1 comment

Comments

@Bublade
Copy link

Bublade commented Mar 13, 2019

I'm submitting a ... (check one with "x")

[ ] bug report
[X] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

In relation to issue #774 after toggling a column back on it will be added to the back of all the other columns. Which is not what my boss wants (he wants it back at the position where it stood). Can you make columnOrder a property also? So that if the property is set the one from the props will be used instead of the state one?

@Bublade Bublade changed the title make columnOrder also a property Add columnOrder as a property instead of state only Mar 13, 2019
@mertsincan
Copy link
Member

You need to do this yourself. Please see; https://codesandbox.io/s/v6royn3440?fontsize=14

class App extends Component {
  constructor(props) {
    super(props);

    let columns = [
      { field: "vin", header: "Vin" },
      { field: "year", header: "Year" },
      { field: "brand", header: "Brand" }
    ];

    this.defaultColOrder = [...columns, { field: "color", header: "Color" }];

    ...
    this.onColumnToggle = this.onColumnToggle.bind(this);
  }

  onColumnToggle(event) {
    let _cols = this.defaultColOrder.filter((colData, index) => {
      return (
        event.value.filter((eventData, index) => {
          return colData.field === eventData.field;
        }).length > 0
      );
    });
    this.setState({ cols: _cols });
  }
...

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