Results 1 to 3 of 3

Thread: How to get a future row based on more than one data property

  1. #1
    Sencha User
    Join Date
    Dec 2018
    Posts
    2

    Default Answered: How to get a future row based on more than one data property

    I know how to use the grid.rowWith to get a future row using one property and its corresponding value but is there a way to get a row based on two or more properties and their values. My thought was that you could do so with rowBy but I didn't find one. I am using webdriver and not in-browser testing. The problem is that a grid could have two rows with the same name but different subsequent values. Getting a row based on a xtype would work as well.

    For example say you have a grid with a store of names:
    fname
    lname
    address1
    city
    adam smith 1 main st new york
    adam jackson 2 main st new york
    paul jackson 1 main st new york







    How do I get the adam jackson row? The purpose is to check the value of all properties in that row.

  2. The Sencha Test APIs don't currently support searching by multiple properties and values for grid rows. For now, you could either search by row index or row id, or if you do need to search by multiple properties, please try the following example:

    Code:
    // WebDriver scenario example.
    // 
    // Scenario URL: https://examples.sencha.com/extjs/6.7.0/examples/kitchensink/frame-index.html?classic#cell-editing
    
    
    describe('Grid tests', function() {
        it('should find a grid row by multiple properties', function() {
            // Define the property values you want to search
            var common = 'Bee Balm',
                light = 'Shade';
            
            ST.grid('cell-editing')
                .and(function(future) {
                    // Set the property names and values on the "future" object
                    future.data = future.data || {};
                    future.data.common = common;
                    future.data.light = light;
                })
                .execute(function(grid) {
                    // This function gets passed to the browser for execution.
                    // In order for it to have access to your property names and values, 
                    // you need to add them to the "future.data" object, as above.
                    var me = this;
                    
                    // Use the Ext JS "findBy" method of the Store to locate a record
                    // index by a custom function, and return the index.
                    return grid.getStore().findBy(function(record, id) {
                        return record.get('common') === me.future.data.common 
                            && record.get('light') === me.future.data.light;
                    });
                })
                .and(function(future) {
                    // "executeResult" contains the return value from the function above.
                    var rowIndex = future.data.executeResult;
                    
                    // Now interact with the grid row, now we know the index
                    ST.grid('cell-editing')
                        .rowAt(rowIndex)
                        .click();
                });
        });
    });

  3. #2
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Redwood City, CA
    Posts
    301
    Answers
    41

    Default

    The Sencha Test APIs don't currently support searching by multiple properties and values for grid rows. For now, you could either search by row index or row id, or if you do need to search by multiple properties, please try the following example:

    Code:
    // WebDriver scenario example.
    // 
    // Scenario URL: https://examples.sencha.com/extjs/6.7.0/examples/kitchensink/frame-index.html?classic#cell-editing
    
    
    describe('Grid tests', function() {
        it('should find a grid row by multiple properties', function() {
            // Define the property values you want to search
            var common = 'Bee Balm',
                light = 'Shade';
            
            ST.grid('cell-editing')
                .and(function(future) {
                    // Set the property names and values on the "future" object
                    future.data = future.data || {};
                    future.data.common = common;
                    future.data.light = light;
                })
                .execute(function(grid) {
                    // This function gets passed to the browser for execution.
                    // In order for it to have access to your property names and values, 
                    // you need to add them to the "future.data" object, as above.
                    var me = this;
                    
                    // Use the Ext JS "findBy" method of the Store to locate a record
                    // index by a custom function, and return the index.
                    return grid.getStore().findBy(function(record, id) {
                        return record.get('common') === me.future.data.common 
                            && record.get('light') === me.future.data.light;
                    });
                })
                .and(function(future) {
                    // "executeResult" contains the return value from the function above.
                    var rowIndex = future.data.executeResult;
                    
                    // Now interact with the grid row, now we know the index
                    ST.grid('cell-editing')
                        .rowAt(rowIndex)
                        .click();
                });
        });
    });
    Daniel Gallo
    Senior Solutions Architect
    Sencha Inc.

  4. #3
    Sencha User
    Join Date
    Dec 2018
    Posts
    2

    Default

    Thanks, from that I was able to get what I needed.

Posting Permissions

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