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

groupOrder array doesn't work when group is a string #424

Closed
eluce2 opened this Issue Apr 13, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@eluce2

eluce2 commented Apr 13, 2018

In my options, I have:
group: "category",
groupOrder: ["Indiana","Arizona"],

And my data contains the following format:
{"category":"Arizona","id":"1","name":"Phil"}
{"category":"Indiana","id":"3","name":"George"}

But the plugin breaks when groupOrder is set to the array (no results found). If I remove the line, it works as expected. If I set groupOrder: "desc", I get results, but all of the Arizona results still show first.

@running-coder running-coder added the Bug label Apr 16, 2018

@running-coder running-coder added this to the 2.10.5 milestone Apr 16, 2018

running-coder added a commit that referenced this issue Apr 16, 2018

@running-coder

This comment has been minimized.

Owner

running-coder commented Apr 16, 2018

I've added a commit on the develop branch, let me know if it fixes your issue

@eluce2

This comment has been minimized.

eluce2 commented Apr 16, 2018

With this change, this now allows my list of data to be searched, but the Indiana users are still not showing up above the Arizona users until I enter more than a few characters. My minLength is set to 0.

@running-coder

This comment has been minimized.

Owner

running-coder commented Apr 18, 2018

indeed this will happen, the reason is simple. By default, Typeahead stops searching as soon as it has the number of results set in option. Since the groups are dynamically built when searching using custom group option, Typeahead will stop searching after it matches x amount and then display the grouped results. It does not re-compile groups first then start searching in the first group, then the second group, etc. This could be something to perhaps do when compiling the source object.

image

instead of seeing myGroup which refers to the configuration object, we would see { Indianna: [...], Arizona: [...] }

Option B would be to reorder the given source on search to allow for dynamic data (Preferred option)

@eluce2

This comment has been minimized.

eluce2 commented Apr 18, 2018

Thanks. I'll be able to restructure my data in order to resolve this.

However, in my use case, the ability to set a default option the dropdownFilter would be much more useful. Then I wouldn't care as much about which order the groups appeared.

running-coder added a commit that referenced this issue Jul 19, 2018

Version 2.10.5
Features
- Feature #397 update data of a multiselect

Fixes
- Fix #389 Allow `onLayoutBuiltBefore` to return a custom template, wrap `<li>` inside other `<ul>` or `<div>`
- Fix #396 limitTemplate doesn't display unless emptyTemplate is defined
- Fix #408 Null values in query data causes a null value error.
- Fix #424 groupOrder array doesn't work when group is a string
- Fix #434 The item value in the onCancel function in undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment