Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Select control options automatically re-sorted when values are numeric.
17/06/2013
21:34
Avatar
Inara
Member
Members
Forum Posts: 26
Member Since:
27/07/2009
sp_UserOfflineSmall Offline

I recently stumbled upon the following issue: For an editable grid (I tested both form edit and inline edit modes), if you pass a select control a value list with only numeric storage values, jqGrid automatically re-sorts the list by the storage values when it converts the values to a dropdown.

For example, if I include the following value list in the editoptions for a select column:

value:{"":"","8":"ACME Inc.","3":"Basic, LLC","7":"Large Corp","2":"Simple Organization","4":"Testing Organization"}

I expect to get the following select list:
<option role="option" value=""></option>
<option role="option" value="8">ACME Inc.</option>
<option role="option" value="3">Basic, LLC</option>
<option role="option" value="7">Large Corp</option>
<option role="option" value="2">Simple Organization</option>
<option role="option" value="4">Testing Organization</option>

Instead, I get this:
<option role="option" value="2">Simple Organization</option>
<option role="option" value="3">Basic, LLC</option>
<option role="option" value="4">Testing Organization</option>
<option role="option" value="7">Large Corp</option>
<option role="option" value="8">ACME Inc.</option>
<option role="option" value=""></option>

Is there any way to turn off this auto-sorting behavior? I would like to be able to display values from the database in alphabetical order while storing their IDs.

19/07/2013
23:55
Avatar
Inara
Member
Members
Forum Posts: 26
Member Since:
27/07/2009
sp_UserOfflineSmall Offline

A quick update on the issue: jqGrid doesn't re-sort the options if they are passed to editoptions as a string (i.e., in the example above, value:":;8:ACME Inc.;3:Basic, LLC;7:Large Corp;2:Simple Organization;4:Testing Organization").

EDIT: Unfortunately, there is no way to escape colon characters when using the string method, so you can't use any options with a colon in them. Since the object notation is the only way to allow all characters, I would consider the sorting bug to be a major issue.

EDIT 2: The bug with object sorting is apparently inherent to the javascript object implementation: Javascript Object Property Order. Would it be possible to switch over to using a pair of arrays (one for keys, one for values) to support a non-string notation that still allows explicit sorting?

EDIT 3: I just found out that there is undocumented support for custom "delimiter" and "separator" options for the string notation model. Is there a reason they're not included in the wiki documentation, or was that an oversight?

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
33 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information