Set "None" as first option

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 25, 2012

Hi All ,

How do we order a list(version picker) using setFieldOptions() in Behaviour plugin? My script is similar to this script.The "None" value appears at any random position . I want it to be at the first postion .

fieldOptions.put ("00000", "None")

The above line helps for Mozilla ,IE8 but in chrome it makes "None" as the last option.

Suggestions, comments welcomed

Thank you

2 answers

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 25, 2012

The None should have a value of -1 if it's the same "None" option as the usual one. Or have you put in 00000 just for an example? I'm reading your question... the map key is the value of the option, not the order.

Anyway, I think there's an outstanding issue regarding ordering of the options... it's probably down to the vagaries of how browsers decide the order of associative arrays right now.

Also, I'm rethinking the future of the behaviours plugin what with the upcoming changes with inline editing, so I'm holding off on dev effort in that area atm.

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2012

The position of "None" is random in the options when i use -1 for all (FF,IE,Chrome) browsers , the position is first when i use 00000 .

I use a treemap<string,string> instead of a map[:] this sorts the options in order but the browser does not displays it in the sorted order.

i am thinking of using setHelpText() to apply a javascript after i set options to the field ,which will sort the order of the options/make none as a first(default) option.

I am not getting how to sort the options with javascript , something like the below js

AJS.$("#customfield_10001 option").sort()

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 13, 2012

I applied a js to the customfield using setHelpText() which checks for 'None' in the list and set it as selected .

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2012

Hi Jamie ,

Is there a way by which i can add a <optgroup> to a version picker field and add new values inside this optgroup except 'None' ?

I think by doing this 'None' will always appear on the top of the list and versions inside the optgroup .

Thank you

Myleen Bacarra June 5, 2018

Are your suggestions applicable to Cloud version of JIRA?

0 votes
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2012

Please can someone help me on this ?

Suggest an answer

Log in or Sign up to answer