Results 1 to 2 of 2

Thread: selecting value from combobox

  1. #1
    Sencha User
    Join Date
    Mar 2017
    Posts
    24
    Vote Rating
    1
      0  

    Default selecting value from combobox

    I'm trying to select a No value from a combobox but I'm matching multiple items because that same value is available in numerous combobox's on the form. Is there a way to select the No value from the currently expanded combobox?

    Code:
    target.expand().down("//li[text()='" + spec.input + "']");                target.type({
                            key: 'Enter'
                        }).wait(200)
                        .and(function(field) {
                            field.expect('value').toContain(spec.value);
                        });

  2. #2
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Redwood City, CA
    Posts
    231
    Answers
    25
    Vote Rating
    28
      0  

    Default

    The combobox renders its items in a boundlist, which is a type of dataview, so you could use the ST.dataView API to interact with it, and locate an item in the list by value using the "itemWith" API, as opposed to using an XPath locator.

    Try something like this:

    Code:
        it('should expand and select a value by the dataview', function() {
            ST.comboBox('combobox[reference="mailingState"]')
                .expand();
            
            ST.dataView('boundlist:visible')
                .itemWith('abbr', 'CA')   // Find a record where the field "abbr" equals "CA"
                .click();
                
            ST.comboBox('combobox[reference="mailingState"]')
                .displayValue('CA');
        });
    You can also use this same approach to click on combobox items by record index:

    Code:
        it('should expand and select a value by the dataview index', function() {
            ST.comboBox('combobox[reference="mailingState"]')
                .expand();
            
            ST.dataView('boundlist:visible')
                .itemAt(3)
                .click();
                
            ST.comboBox('combobox[reference="mailingState"]')
                .displayValue('AR');
        });
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

Similar Threads

  1. Replies: 2
    Last Post: 6 Oct 2016, 8:39 AM
  2. Replies: 4
    Last Post: 13 Jul 2012, 10:57 PM
  3. HELP! Selecting ComboBox value
    By elnove in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 20 Mar 2008, 10:42 AM
  4. ComboBox selecting first row
    By djMax in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 14 Sep 2007, 2:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •