Success! Looks like we've fixed this one. According to our records the fix was applied for EXTGWT-2735 in a recent build.
  1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    6
    Vote Rating
    0
    megalobrainiac is on a distinguished road

      0  

    Default Keep ComboBox on selected item on expand

    Keep ComboBox on selected item on expand


    When I create a simple combo box I see that, when I expand, it starts at the selected item but then scrolls to the top. Is there a way to keep it scrolled to the selection?

    Code:
    public class ComboBoxScrollToTop implements EntryPoint {
    
      @Override
      public void onModuleLoad() {
       SimpleComboBox<String> field = new SimpleComboBox<String>(new StringLabelProvider());
       field.setTriggerAction(TriggerAction.ALL);
       for (int i = 1; i < 100; i++) {
         field.add(String.valueOf(i));
       }
       field.setValue("90");
       RootPanel.get().add(field);
      }
    }

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    I've moved this to our Bugs forum and opened an internal issue to track this - this can pretty clearly be reproduced on http://www.sencha.com/examples/

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    It appears I'm mistaken, and that this has been fixed - the issue that can be reproduced at the link above cannot be seen on the nightly build at http://staging.sencha.com:8080/examp...Place:combobox

    Here's a workaround that seems to be a workaround in a 3.0.1 project:

    Code:
       field.addExpandHandler(new ExpandHandler() {
        @Override
        public void onExpand(ExpandEvent event) {
          String selected = field.getValue();
          final int index = field.getStore().indexOf(selected);
          Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            @Override
            public void execute() {
              field.getListView().getElement(index).scrollIntoView();
            }
          });
        }
      });

Thread Participants: 1