Repository navigation
Disable automatic sort #1706
|
Hi, I'm receiving a pre-ordered list (JSON) but when I loaded into the selectize control, it re-orders the list by the Id and I don't want this. How I can let selectize use the order of my JSON? This is the JSFiddle example: Thanks. |
Replies: 43 comments
|
I would also like to be able to disable automatic sorting. It's really, really frustrating that Selectize automatically messes with the order of options that are added to it. Is there no way to disable autosort? |
|
@eliashdez @erlingur Remove |
|
@antsa I don't have that. I use the default configuration of |
|
And you are using The example of @eliashdez seemed to work differently with loading the data from JSON, where sorting happened. Here the trick seemed to be to set the |
|
@antsa Yes. Here is a jsfiddle demonstrating the problem: http://jsfiddle.net/8H62B/6/ When you first load the page with it works fine but when I attempt to update the select with new options it will auto sort them. On that jsfiddle, if you begin by looking at the options, then click the button and look at the options again you will see what I mean. |
|
@erlingur Apparently when adding options it does sorting and doesn't use the original order of the data—would it work for you to set the order with e.g. When calling selectize on a existing select with options leaving that option out will keep the original order of the option elements. |
|
@antsa sortField: 'text' will sort the options based on their text right? That wouldn't work for me since I have presorted options that are not really based on either the value or the name. I would ideally need addOptions() to respect the insert order. I'm looking at it now, trying to make it do that. |
|
So I created a pull request with a proposed fix. What do you think @antsa? |
|
I need it too |
|
Hey @ai, I created a pull request for this here: #295 You can use this branch if you want this functionality now: https://github.com/Reiknistofa/selectize.js/tree/respect_insert_order_in_addoption |
|
👍 |
|
+1 |
|
+1 |
|
+1 |
|
👍 will this be merged? |
|
Still no way to disable auto sort? When I reorder with the |
|
Still nothing here? Im facing the same problem. |
|
Ping! |
|
When exporting from database, make a column with a count and use that? |
|
Same here. |
|
+1 |
|
Still have this bug! Help! |
|
Despite this issue being closed, I'm still having it 5 years after it was opened, as are others it seems. (with version 0.12.4). I'm about to ditch selectize altogether because of this. The |
|
This works for me: It disables the default sorting and the search function keeps working as expected |
|
Still have this bug |
score: function () {
return function () {
return 1
}
},Seems to be a working hack. @brianreavis posted here and mentioned #640 (comment) where he said:
|
|
Use |
|
@urmamb that's true for maybe most of the cases, but there are others where the server wants to prioritise some results over others (new movies, important people) and wants to show them first. This doesn't mean that after the first results, if you continue typing, selectize could search and sort it out, but the first results should (with at least a flag/option) be unsorted. |
|
This works for me for When typing to search, it respects the original order of options. |
|
@xhafan This works for me as well, excellent workaround. |
This works for me for
selecttag with options:When typing to search, it respects the original order of options.
Taken from #196 (comment) and simplified for my case.