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

Reorder column #5827

Closed
bschootcovadis opened this issue Aug 10, 2021 · 11 comments · May be fixed by #7468
Closed

Reorder column #5827

bschootcovadis opened this issue Aug 10, 2021 · 11 comments · May be fixed by #7468
Labels
Bug Issues which are marked as Bug confirmed Issues that have been confirmed with a reduced test case and identify a bug. reorder-columns Issues for the reorder-columns extension.

Comments

@bschootcovadis
Copy link

Is there a way to reorders columns by calling a function manually.

I am saving the column order to the cookies using the library but the data underneath is not loading in the correct header.

The moment i change a column all the data will be in ordered in their correct header.

@bschootcovadis bschootcovadis added the help-wanted Issues we need or would love help from the community to resolve. label Aug 10, 2021
@UtechtDustin
Copy link
Collaborator

So your real issue is that the order is incorrect after a reload ?
Then please provide us an example using our editor.

But yes, there is a method. Just check the documentation there is only one method for that extension.

@UtechtDustin UtechtDustin added the awaiting reply Issues that are awaiting reply, will be closed if there is no any response in 7 days. label Aug 10, 2021
@bschootcovadis
Copy link
Author

bschootcovadis commented Aug 10, 2021

https://live.bootstrap-table.com/code/bschootcovadis/8602

Steps to reproduce:

  1. Move headers
  2. Check row values
  3. Refresh page

Headers are set correct, rows with the data are not correct

Sorry for the late reply

@UtechtDustin
Copy link
Collaborator

UtechtDustin commented Aug 10, 2021

You're right, i can confirm that this is a bug.
Thanks for the report.

@UtechtDustin UtechtDustin added Bug Issues which are marked as Bug confirmed Issues that have been confirmed with a reduced test case and identify a bug. reorder-columns Issues for the reorder-columns extension. and removed awaiting reply Issues that are awaiting reply, will be closed if there is no any response in 7 days. labels Aug 10, 2021
@bschootcovadis
Copy link
Author

bschootcovadis commented Aug 10, 2021

After some debugging I found it it has to do with the bootstrap-table.js file on the function init to be exact this.initBody()

I do not know how to fix it (I suck at javascript) 😢

@wenzhixin wenzhixin removed the help-wanted Issues we need or would love help from the community to resolve. label Nov 8, 2021
@richard-313
Copy link

@UtechtDustin
Is there a fix now? Its still not working https://live.bootstrap-table.com/code/s72817/13367

  1. reorder column
  2. reload

@UtechtDustin
Copy link
Collaborator

@s72817 the issue is still open, which means there is no fix right now.

@richard-313
Copy link

ok, thank you :)

@richard-313
Copy link

solution could be to include / save column order into cookies? right now, cookies dont support reorder columns, right?

@dkmax
Copy link

dkmax commented Oct 31, 2023

I don't know if this is still a problem for someone, but i went through a workaround.

1 : in bootstrap-table-cookie.js
In function initHeader(), create a new array with ordered columns using this.columnsSortOrder, then apply this new array as this.options.columns[0] (options columns in the datatable)
Note that you must change the column.fieldIndex when creating the new array (so that formatters can follow the changes)

2 : in bootstrap-table.js
In function initRow(), there is a foreach over this.header.fields , use this.options.columns[0] in place of headers.fields.
Then, inside the foreach loop change the var column = from columns[j] to options.columns[0][j]

Hope this will help some

@dkmax
Copy link

dkmax commented Dec 14, 2023 via email

@wenzhixin
Copy link
Owner

Duplicate of #6728

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues which are marked as Bug confirmed Issues that have been confirmed with a reduced test case and identify a bug. reorder-columns Issues for the reorder-columns extension.
Projects
None yet
5 participants