1. #1
    Sencha User LoriSun's Avatar
    Join Date
    Jan 2009
    Location
    China, Dalian
    Posts
    32
    Vote Rating
    1
    LoriSun is on a distinguished road

      0  

    Default Please Add onSelect event for combobox.

    Please Add onSelect event for combobox.


    Hi Gxt guys,

    I'm using gxt beta4 now, could you please add onSelect event/Handler for com.sencha.gxt.widget.core.client.form.ComboBox in next version? I think this is necessary event for developers.

    for now I modified some in comboboxcell to do this, but I feel this is not formal approach:

    Code:
    public class ComboboxCell2DisableNativeQuery<T> extends ComboBoxCell<T> {
        private static final Logger    logger    = Logger.getLogger( ComboboxCell2DisableNativeQuery.class.getName() );
        
        public OnSelectProvider<T> provider;
        
        public interface OnSelectProvider<T> {
            void onSelect( T item );
        }
    
        public ComboboxCell2DisableNativeQuery( ListStore<T> store, LabelProvider<T> labelProvider,
                SafeHtmlRenderer<T> viewLabelProvider, OnSelectProvider<T> provider ) {
            super( store, labelProvider, viewLabelProvider );
            this.provider = provider;
        }
        
        public ComboboxCell2DisableNativeQuery( ListStore<T> store, LabelProvider<T> labelProvider,
                SafeHtmlRenderer<T> viewLabelProvider ) {
            super( store, labelProvider, viewLabelProvider );
        }
    
        public ComboboxCell2DisableNativeQuery( ListStore<T> store, LabelProvider<T> labelProvider ) {
            super( store, labelProvider );
        }
    
        public ComboboxCell2DisableNativeQuery( ListStore<T> store, LabelProvider<T> labelProvider, ListView<T, ?> view ) {
            super( store, labelProvider, view );
        }
    
        @Override
        protected void onSelect( T item ) {
            super.onSelect( item );
            provider.onSelect( item );
        }
    
        @Override
        protected void onTriggerClick( com.google.gwt.cell.client.Cell.Context context, XElement parent, NativeEvent event,
                T value, com.google.gwt.cell.client.ValueUpdater<T> updater ) {
            //super.onTriggerClick( context, parent, event, value, updater );
            //just expend or collapse.
            if ( isExpanded() ) {
                collapse( context, parent );
            } else {
                expand( context, parent, updater, value );
            }
        }
    
        @Override
        public void doQuery( com.google.gwt.cell.client.Cell.Context context, XElement parent,
                com.google.gwt.cell.client.ValueUpdater<T> updater, T value, String query, boolean force ) {
    
        }
    }
    Useage:
    Code:
            cb_users = new ComboBox<UserDto>( new ComboboxCell2DisableNativeQuery<UserDto>( store4Cb_users,
                    new LabelProvider<UserDto>() {
                        @Override
                        public String getLabel( UserDto item ) {
                            return UserUtil.getProperUserName( item );
                        }
    
                    }, new SafeHtmlRenderer<UserDto>() {
                        @Override
                        public SafeHtml render( UserDto item ) {
                            return getProperNameSafeHtml( item );
                        }
    
                        @Override
                        public void render( UserDto item, SafeHtmlBuilder builder ) {
                            builder.append( getProperNameSafeHtml( item ) );
                        }
    
                    }, new OnSelectProvider<UserDto>() {
                        @Override
                        public void onSelect( UserDto item ) {
                            presenter.doSearch( item.getId() );
                        }
                    } ) );
    Sencha fans

  2. #2
    Sencha User WesleyMoy's Avatar
    Join Date
    Oct 2009
    Location
    Redwood City, California
    Posts
    402
    Vote Rating
    2
    WesleyMoy is on a distinguished road

      0  

    Default


    ComboBox now fires SelectionEvent when an item in the drop down list is selected. This allows you to react to the user choosing an item from the drop down list without waiting for the user to move focus away from the combo box.

    Look for this change in the Release Candidate build.

Thread Participants: 1