[richfaces-issues] [JBoss JIRA] (RF-4308) rich:pickList: keep sort order of source list after add/remove operations

Brian Leathem (JIRA) jira-events at lists.jboss.org
Mon Nov 18 18:03:06 EST 2013


    [ https://issues.jboss.org/browse/RF-4308?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924687#comment-12924687 ] 

Brian Leathem commented on RF-4308:
-----------------------------------

RichWidget issue [#137|https://github.com/richwidgets/richwidgets/issues/137] has been resoloved; the client-side hook is now in place.  Further work required to resolve this issue involves:

# Extending [ClientSelectItem|https://github.com/richfaces/richfaces/blob/master/framework/src/main/java/org/richfaces/ui/select/ClientSelectItem.java] to track the sequence number of the Selectitem in the pick list
# Adding a _data-rf-index_ attribute to the items in the pick list [CDK template|https://github.com/richfaces/richfaces/blob/master/framework/src/main/java/org/richfaces/ui/select/pickList/pick-list.template.xml]
# Adding a _sortFunction_ option to the pick-list widget invocation in the [pick-list-bridge|https://github.com/richfaces/richfaces/blob/master/framework/src/main/resources/META-INF/resources/org.richfaces/bridge/select/pick-list-bridge.js]

----

In the mean time, a workaround would be to implement your own pick list widget _sortFunction_ by listening for the widget _create_ event:
{code}
$('<my-selector>').on('picklist', 'create', function(a, b) {
   return ...
});
{code}

A concrete example of this looks like:
{code}
$('#list').on('picklistcreate', function(event, ui) {
  $('#list').pickList('option', 'sortFunction', function(a, b) {
    return $(a).data('key') - $(b).data('key');
  });
});
{code}
                
> rich:pickList: keep sort order of source list after add/remove operations
> -------------------------------------------------------------------------
>
>                 Key: RF-4308
>                 URL: https://issues.jboss.org/browse/RF-4308
>             Project: RichFaces
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 3.2.2
>            Reporter: Martin Höller
>              Labels: order, picklist, sort
>             Fix For: 5-Tracking
>
>
> When adding items from the source list to the target list and removing this items again, the original order of the source list is not preserved. This makes it hard to find items in a list that is longer than just a fest items. A good example is the second example on the livedemo at http://livedemo.exadel.com/richfaces-demo/richfaces/pickList.jsf. Add the first state (Alabama) and remove it. It can now be found at the very end of the otherwise alphabetical list of states. This can be rather unintuitive for a user.
> My suggestion is either remember the original sort order of the source list, or add some attribute that enables automatic sorting.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the richfaces-issues mailing list