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

Option to use a function to resolve group label #80

Closed
matdurand opened this Issue Sep 19, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@matdurand

matdurand commented Sep 19, 2015

I have a cause where I have a "type" property on my json objects, but I can't use it to create a group label. If we were able to pass a function somehow to the group option, it would be more flexible to create the label.

@running-coder

This comment has been minimized.

Owner

running-coder commented Sep 22, 2015

hey dreamagex, have you looked inside the group option?

If set to string, the results will be grouped by the corresponding object key.
Ex: group: "conference" will group the hockey teams by "Western" and "Eastern" conferences in hockey_v1 demo
If an Array is set the second index will set a custom header text.
Ex: group: ["conference", "{{group}} conference Hockey Teams"], "{{group}}" will be replaced by the value of "conference"

@running-coder running-coder added Support and removed New Feature labels Sep 22, 2015

@matdurand

This comment has been minimized.

matdurand commented Sep 22, 2015

Yes I've looked at it, but as far as I can tell, the labels of the group is either the source name, or a property of the items from the data. I have neither. I have a "type" property on my items matching my groups, but it's not a label, it's like "type1", "type2", "type3". Suppose I want to display Countries for type1, States for type2 and Cities for type3, my only option is to name the sources accordingly. But then my site display in 2 languages, so I would have to change the javascript to rename the source depending on the language, which is a mess.

The only other option is to change the JSON to include the labels (which I did since I didn't find any other way).

If the group option permitted something like this:

group: ["type", function(groupName) {
if (groupName == 'type1') return countryLabel;
if (groupName == 'type2') return statesLabel;
if (groupName == 'type3') return citiesLabel;
}]
I would be able to change countryLabel, statesLabel and citiesLabel to the proper value depending on the language.

Anyway it's just an idea. I don't want to push to hard for this since I already modified my json to include the group labels, but since I got this issue, I thought it would be nice to open an issue about this.

Nice job btw, you plugin is very neat!

@running-coder

This comment has been minimized.

Owner

running-coder commented Sep 22, 2015

oh! having the option to pass a function as the second param there shouldnt be too hard
thanks for the suggestion

@running-coder running-coder modified the milestones: 2.1.4, 2.2.0 Oct 22, 2015

running-coder pushed a commit that referenced this issue Nov 10, 2015

tom bertrand
Version 2.2.0
#76, #95 Added groupOrder option
#80 Option to use a function to resolve group label
#90 options.cache< now accepts "true", "localStorage" or "sessionStorage"
#102 Add UMD wrapper

Fixes
#101 Uncaught TypeError: this.xhr[i].abort is not a function
#103 Typo in dropdownCarret option, now dropdownCaret

running-coder pushed a commit that referenced this issue Nov 10, 2015

tom bertrand
Version 2.2.0
#76, #95 Added groupOrder option
#80 Option to use a function to resolve group label
#90 options.cache< now accepts "true", "localStorage" or "sessionStorage"
#102 Add UMD wrapper

Fixes
#101 Uncaught TypeError: this.xhr[i].abort is not a function
#103 Typo in dropdownCarret option, now dropdownCaret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment