Skip to content

Remote sort reset/clean broken by changes made for #1752. #1789

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

Closed
dawnmist opened this issue Dec 4, 2017 · 3 comments
Closed

Remote sort reset/clean broken by changes made for #1752. #1789

dawnmist opened this issue Dec 4, 2017 · 3 comments

Comments

@dawnmist
Copy link

dawnmist commented Dec 4, 2017

The changes made for Issue #1752 breaks the ability to remove/reset a sort when remote sorting is used.

Prior to this change, clearing a sort used to work by:

  • Using Table.cleanSort(), and
  • Setting SortOrder = undefined, SortName = '' in the table options.

Doing this with 4.2.0 (I would assume in 4.1.5 - I just tried upgrading from 4.1.4) results in BootstrapTable throwing the error: "The type of sort field and order should be both with String or Array".

The changes made for issue #1752 do not take into account/provide any way to reset the current sort without triggering the above error. i.e. TableDataStore.setSortInfo(sortOrder, options.sortName) enforces that sortOrder must never be undefined.

@AllenFang
Copy link
Owner

@dawnmist when you got the error? call cleanSort? or set sortName and sortOrder? and are you using the remote sort right?

Regards,
Allen

@dawnmist
Copy link
Author

dawnmist commented Dec 4, 2017

Yes, using remote sorting.
Yes, occurs when Option.SortOrder = undefined and Options.SortName = ''.

This commit introduced the problem, because the function it calls validates that SortOrder must be the same type as SortName - but when there is no sort SortOrder (previously) was undefined. So the test fails and throws the Error "The type of sort field and order should be both with String or Array". 06b3560

@AllenFang
Copy link
Owner

@dawnmist I see, I think the sortName is supposed to be undefined right? i know this patch will break your program and make you feel this might be a bug. Yes, that's a problem that I didn't handle it well at before. Anyway, I'll suggest to clean the sort status by undefined in this circumstances.

A example I used it before: https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/sort/manage-sort-external-table.js#L28-L29

Please let me know if you have any question or idea, thanks a lot !!!

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