Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

optgroup order? #499

Closed
Closed

Description

@joshuataylor

Is it possible to order multiple optgroups?

Let's say I have fruits and vegetables, would it be possible to put fruits above vegetables?

Activity

  1. NotSqrt commented on Jul 30, 2014

    @NotSqrt

    There's an option called ''optgroupOrder'' for this.

  2. brianreavis commented on Jan 30, 2015

    @brianreavis
    Member

    This has changed a little in 0.12.0. Now, set the $order property on each item in your optgroups array.

  3. shurfee commented on Dec 12, 2016

    @shurfee

    @brianreavis, could you please give an example how to implement your advice?

    I need to sort optgroups by its labels, is it possible?

    In my "options" code for selectize there is a key sortField with a value of "text". But it sorts only options by its inner text.
    And I need to sort not only options inside optgroup, but also optgroups themselves.

    <optgroup label="1"> <option>Text ABC</option> </optgroup>
    <optgroup label="2"> <option>Text BCD</option> </optgroup>

  4. adamgins commented on Aug 10, 2017

    @adamgins

    @brianreavis thanks for the great package. I am using 0.12.1_5

    can't seem to get it to pick up the $order, I have optgroups: [{$order: 1, group:'role',name:'Role'}, {$order: 2,group:'team',name:'Team'}, {$order: 3,group:'people',name: 'Participants'}]

    but it renders in the wrong order. I tried changing the numbering, in reverse... no luck I see items in this order Participants, Team, People regardless of the $order param/val

    update: I upgraded to 0.12.4 , same issue

  5. brjadams commented on Dec 22, 2017

    @brjadams

    @adamgins had the same issue. Saw the optgroup examples from selectize, where the added the 'lockOptgroupOrder' flag. Seems to fix it. I'm using 0.12.1.

    Just add 'lockOptgroupOrder: true' to your selectize options on initialize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions