Forum Discussion

Don's avatar
Don
Contributor
7 years ago
Solved

WebApp: Clicking on a button in a grid cell

Hello Community.   I'm having an issue that I can't figure out and hopefully someone can help me. I have a grid on a web application that has several rows and columns. I know the sample pic below s...
  • tristaanogre's avatar
    7 years ago

    Can you post the code of what you've actually tried?  

     

    Here's what we're doing. These two functions combined can take any table and, given the particular set of parameters, click on the child link within the found cell within the table.

    function findRow(tableObject, stringSearch, searchColumn, maxRows = 0) {
        var cellFound = Utils.CreateStubObject();
        var upperLimit;
        if (maxRows == 0) {
            upperLimit = tableObject.RowCount;
        } 
        else {
            upperLimit = maxRows;
        } 
        if ((searchColumn == 999) || (searchColumn == undefined)) {
            cellFound = tableObject.FindChild('innerText', aqConvert.VarToStr(stringSearch) + '*', 0, true);
        }
        else {
            for (var i = 1; i < upperLimit; i ++) {
                if (aqString.Trim(tableObject.Cell(i, searchColumn).innerText) == aqString.Trim(aqConvert.VarToStr(stringSearch)) ) {
                    cellFound = tableObject.Cell(i, searchColumn);
                    break;
                } 
            
            } 
        }
        if (cellFound.Exists) {
            return cellFound.RowIndex;
        }
        else {
            return -1;
        }
    }
    
    function clickTableColumn(stringToFind, objectTableInput, colIndexToClick, searchColumn = 999) {
    
        var rowFound;
        if (objectTableInput.Exists) {
            rowFound = findRow(objectTableInput, stringToFind, searchColumn);
            objectTableInput.Cell(rowFound, colIndexToClick).Child(0).scrollIntoView(true);
            objectTableInput.Cell(rowFound, colIndexToClick).Child(0).Click();    
            }
        else { 
            throw Error('Unable to find the table '+ objectTableInput.MappedName) ;
        }               
    }