optgroups
I want to help with this future... i was thinking going with simple structure
var options = [{
label: "Group 1",
children: [{
value: "one",
lable: "One"
}, {
value: "two",
lable: "Two"
}];
is someone started to work on that?
I also need this, immediately. Is there work in progress, or should I fork?
+1
+1
Anyone working on this?
I also would love this. Planning on switching from Selectize.js (which has optgroup support) to this, but would need this functionality first.
+1
+1
We're accepting PRs, so don't feel bad if you beat @jossmac to it. It currently isn't on the hit list.
I'm working almost exclusively on http://elemental-ui.com for the foreseeable future, so I won't be of much help I'm afraid. Incidentally I've implemented a dropdown over there that may be of interest using the following pattern:
var selectOptions = [
{ type: 'option', value: 'option', label: 'Option' },
{ type: 'option', value: 'another-option', label: 'Another option' },
{ type: 'option', value: 'something-else-here', label: 'Something else here' },
{ type: 'divider' },
{ type: 'label', label: 'Select label' },
{ type: 'option', value: 'separated-option', label: 'Separated option' },
];
More here: https://github.com/elementalui/elemental/blob/master/src/components/Dropdown.js
Ping @JedWatson for preferences on implementation details
+1
@JedWatson I'm currently working on this for a project. How would you like this implemented? The interface we need is a variation on the selectize structure, but I can handle that in a wrapper class if you prefer something different:
options: [
{optgroup: 'Things', value: "thing1", label: "Thing 1" },
{optgroup: 'Things', value: "thing2", label: "Thing 2" },
{optgroup: 'Things', value: "thing3", label: "Thing 3" },
{optgroup: 'Stuffs', value: "stuff1", label: "Stuff 1" },
{optgroup: 'Piles', value: "pile1", label: "Pile 1" },
{value: "pile1", label: "Pile 1" }
],
optgroups: [
{position: 1, label: 'Things'},
{position: 2: label: 'Stuffs'}
],
Options with an optgroup not in the optgroup set are ignored. Options without an optgroup are listed last.
@zenjyn :+1: great if you working on public branch i can help with something ( would love to see this merged... and kill select2 at my project
what do you think about something like this ? then you can sort the whole options array by label (if we have values the render it as optgroup )
options: [
{
label: "Thing 1a",
//value: "allThings1a" then in future we can also add selecting the whole group
values: [
{
value: "thing1a", label: "Thing 1a"
},
{
value: "thing2a", label: "Thing 2a"
}
]
},
{
label: "Thing 2b",
values: [
{
value: "thing1b", label: "Thing 1b"
},
{
value: "thing2b", label: "Thing 2b"
}
]
},
{
label: "Thing 3c",
value: "thing3c"
}
];
@piecyk I started with something like that on our end but determined that being able to add, remove, reorder the optgroups in their own array was slightly more flexible for our purposes. I'm still open to something more like your nested structure for the PR, however.
As far as group selecting goes, I wasn't planning on getting into that just yet, but we could make a group select flag then just enable a toggleGroup callback to the onClick event for optgroup divs. Thoughts?
+1
@zenjyn @piecyk any progress on a public branch? I'd be willing to help out too, I need this for a project very soon.
/cc @colbyr
@banderson the optgroup issue for my project was pushed to the backlog almost immediately after I posted on here. I probably won't get to it unless it's still unimplemented by the time the task comes up again. For my project I believe it's on the roadmap 6 months out or so.
+1
+1
:+1:
Trying to kick this thing up again...
@piecyk - I like your proposed API, but I would rename values to children. I think it's a bit more obvious what the purpose is, and a bit easier to read (ie, easier to distinguish between the value and the children). Anyone else fine with that API? If we get some more feedback on that API, it will be easier to start in on it.