Skip to content

Commit 0459ac8

Browse files
committed
Results for grouped options (see select2#4662)
1 parent 787d20e commit 0459ac8

1 file changed

Lines changed: 43 additions & 2 deletions

File tree

docs/_includes/options/data/ajax.html

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,59 @@ <h3>
3232
{
3333
"results": [
3434
{
35-
"id": "1",
35+
"id": 1,
3636
"text": "Option 1"
3737
},
3838
{
39-
"id": "2",
39+
"id": 2,
4040
"text": "Option 2"
4141
}
4242
],
4343
"pagination": {
4444
"more": true
4545
}
4646
}
47+
{% endhighlight %}
48+
49+
<h4>Results for grouped options</h4>
50+
51+
<p>
52+
When options are to be generated in <code>&lt;optgroup&gt;</code> sections, options should be nested under the <code>children</code> attribute of each group object:
53+
54+
{% highlight json linenos %}
55+
{
56+
"results": [
57+
{
58+
"text": "Group 1",
59+
"children" : [
60+
{
61+
"id": 1,
62+
"text": "Option 1.1"
63+
}
64+
{
65+
"id": 2,
66+
"text": "Option 1.2"
67+
}
68+
]
69+
},
70+
{
71+
"text": "Group 2",
72+
"children" : [
73+
{
74+
"id": 3,
75+
"text": "Option 2.1"
76+
}
77+
{
78+
"id": 4,
79+
"text": "Option 2.2"
80+
}
81+
]
82+
}
83+
],
84+
"paginate": {
85+
"more": true
86+
}
87+
}
4788
{% endhighlight %}
4889

4990
<h3>

0 commit comments

Comments
 (0)