Forum Discussion

prabhjot88singh's avatar
prabhjot88singh
Contributor
5 years ago

How to get Data from Data Grid/DATA Table

Hi Team,

I Have created a record and post creation , it saves the table in the Data Grid.

Attached screenshot.

 

Please share the code or snippet to store the First record of the Data table into a variable and print it.

 

 

8 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    Without knowing the properties of your grid, and scripting language we can't help you. We need a lot more information.

    • RUDOLF_BOTHMA's avatar
      RUDOLF_BOTHMA
      Community Hero

      Agreed.  Could you supply a bit more information ?  It's not even entirely clear to me whether you are doing desktop or web testing - it looks like web, but you never know.  How do you intend to use the data ?  In other words, do you need to know all the values in the rows, are only interested in one of the fields etc.

      • prabhjot88singh's avatar
        prabhjot88singh
        Contributor

        Hello Rudolph and Team,

         

        Please note my response below:

         

        1. Yes, it is a web based testing application.

        2. As part of our project, I am interested in fetching both the things from data table 

        a. How to retrieve all the rows values/data inside these rows

        b. Also there is one test case wherein I need to fetch particular cell value from a column.

         

        Please See the screenshot attached, I would like to fetch firstly all the rows from this data table to a List or array.

         

        Ands secondly I also need all Employee IDs(column Number 4) from this web table to be stored somewhere in the variable, so that I can use this column value for expected data output comparison.

         

        Please share your responses, as it is quite urgent.

    • prabhjot88singh's avatar
      prabhjot88singh
      Contributor

      Hi, 

      Please find attached the Object Browser tree for the grid view.

      Please advise on how to get the first row ,specific column data printed

       

      Best,

      Prabhjot

      • RUDOLF_BOTHMA's avatar
        RUDOLF_BOTHMA
        Community Hero

        To make life easier on yourself, you should probably Name Map Panel("transactionTypeGridDiv") to something like TransactionTypeTable

         

        Although it might change from grid to grid, my guess is that panel(1) is your first row of data.

         

        That means that to get the entire first row, you would be using a findchild something like so:

        var PanelWithRow1 = Aliases...TransactionTypeTable.FindChildEx("Panel","1",1);
        
        var childPanelWithData = PanelWithRow1.FindChildEx("Panel","0",1); 
        //or ("Panel","1",1); if that's the panel with the data in var dataArray = childPanelWithData.FindAllChildren(cellcontainer,uniqueidentifierofcells).toArray(); //uniqueidentifierofcells can be a wildcard e.g. "*" you may need to use multiple properties and values e.g objecttype=textbox and visible=true //dataArray now has all the cells in your first data row and you can read from the array