Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SelectItem, order of selected items

    Hi all,

    I have a select list with 5 items in it. If the users selects 5th item, and then the 1st item the display field looks like this: "1st item, 5th item"

    Is there anyway to tell which one the user selected first? Or is there a way to make the list add selected values to the end? So it'll look like this: "5th item, 1st item"

    Thanks

    #2
    Here is the solution:

    Code:
    ListGridField grid1= new ListGridField( "gridName" );
    SelectItem dbItem = new SelectItem();
    dbItem.setMultiple( true );
    dbItem.setValueField( "gridName" );
    dbItem.setOptionDataSource( dataSource);
    dbItem.setAnimatePickList( true );
    dbItem.addChangeHandler( new ChangeHandler()
    {
         public void onChange( ChangeEvent event )
         {
              Record selectedRecord = envPipGrid.getSelectedRecord();
              int edited = envPipGrid.getRecordIndex( selectedRecord );
              String[] oldValue = event.getOldValue().toString().split( "," );
              String[] newValue = event.getValue().toString().split( "," );
    
              for ( int i = 0; i < oldValue.length; i++ )
              {
                   if ( !newValue[i].equalsIgnoreCase( oldValue[i] ) )
                   {
                        envPipGrid.setEditValue( edited, "gridName", oldValue[i] + "," + newValue[i] );
                        break;
                   }
              }
         }
    } );
    
    grid1.setEditorType( dbItem );
    Last edited by bsener; 21 Dec 2011, 08:03.

    Comment

    Working...
    X