jquery - Sort jQGrid's select options by label not by value -


what experiencing jqgrid sorts select options value, , can't find way make sort label.

the options loaded locally:

var cities = {     "15604":"akashi",     "7538":"lompolo",     "13488":"akersloot",     "15516":"akita",     "17301":"akizuki",     "15848":"akola",     "11415":"akron",     "15224":"akron",     "7458":"akrotiri",     "10783":"aksaray",     "15127":"aksu",     "9563":"aktobe" }; 

but options appears this:

<option role="option" value="7458">akrotiri</option> <option role="option" value="7538">lompolo</option> <option role="option" value="9563">aktobe</option> <option role="option" value="10783">aksaray</option> <option role="option" value="11415">akron</option> <option role="option" value="13488">akersloot</option> <option role="option" value="15127">aksu</option> <option role="option" value="15224">akron</option> <option role="option" value="15516">akita</option> <option role="option" value="15604">akashi</option> <option role="option" value="15848">akola</option> <option role="option" value="17301">akizuki</option> 

and portion used it:

//other colmodels, {     "name":"city_id",     "index":"city",     "width":"100",     "editable":true,     "align":"center",     "edittype":"select",     "formatter":"select",     "editoptions":{"value":cities},     "stype":"select",     "searchoptions":{         "sopt":["eq","ne"],         "value":cities} } //other colmodels 

how can make select options sorted label , not values when adding or editing record?

it's not correct. jqgrid don't sort select options @ all. can still have problem order of select options if use object of value property. the answer describe why form can follow changing order of options. it's interesting order depend on browser use. fix problem can use either string form of value property or can use dataurl alternatively.

updated: suspected used object format of value have problems described in the answer. should change cities object string "15604:first labele;9563:second label;...;12345:last label".

i recommend additionally consider use jquery ui autocomplete instead of <select>.


Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -