Forum Discussion

BillSimpson's avatar
BillSimpson
Occasional Contributor
10 years ago

Setting the current active row on an Infragistics XAMDataGrid

I would like to be able to set the current active row on a XamDataGrid.

 

I can find the row by searching for the "Testcomplete Import 1" data value in the datacolumn "Description" on the XamDatGrid called "ListOfMTOsGrid"

 

Set ListOfMTOsGrid = Griddemo.Find("NativeClrObject.Name", "ListOfMTOsGrid", 50)
row = ListOfMTOsGrid.FindRow("Description", "Testcomplete Import 1")
 
if row = -1 then
    Log.Message("Row not found")
    Runner.Halt
end if 
' the above commands gets  the row index I am looking for.

' the following does not work?
CurrentRow = ListOfMTOsGrid.FindId(row)  
Set ListOfMTOsGrid.ActiveRecord = CurrentRow

 

Regards

Bill Simpson

 

  • You can change the active row by clicking the row indicator:

    ListOfMTOsGrid.ClickRowIndicator(row)  
  • It looks like you are assigning a row object to "CurrentRow".

     

    Then you are trying to use that stored object to set the "ActiveRecord" property of "ListOfMTOsGrid".

     

    I'm not familiar with this particular type of grid, but it strikes me that the "ActiveRecord" is likely to be an integer rather than an object? As I say, just a guess.

     

    Also, DataGrid type object often have an underlying DataSet or RecordSet object with a lot of pointers in there and the front facing GUI (the grid object you see) is only a facing. The actual current row/column pointers are stored and controlled by the DataSet/RecordSet object in the backgound. You have to interact with this in order to trigger changes in the front faving Grid object.

     

    Also, when the user clicks a row, it may well be setting off event triggers which won't happen if you try and assign the current row directly.

     

    Certainly, this is my experience with Delphi DataGrids. Not sure about your one, but you might want to have a dig around it's properties and if you find anything like DataLink, DataSet, RecordSet or something like that, then you have an underlying data layer you may need to consider.

    • BillSimpson's avatar
      BillSimpson
      Occasional Contributor

      Hi Colin

       

      Thanks for the ideas, on solving this. As you say there are multiple objects and pointers to get to the data or method that you need to find. Setting ActiveRow would work within the XamDataGrid development world, but does not appear assignable  from TestComplete. Problem is there are so many fields, properties and methods that just generally need an "Object" that it takes ages to find the ones that you can interact with that fires all the correct events so that the UI and the underlying data objects are in sync This is a WPF app under test the uses MVVM, and there are a large number of nested objects. TestComplete is not that quick in running in debug mode, to get to the breakpoints and examine the locals and watch variables.

       

      The solution subsequently suggested by HKosova appears to get me past that problem

       

      ListOfMTOsGrid.ClickRowIndicator(row)

       

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    You can change the active row by clicking the row indicator:

    ListOfMTOsGrid.ClickRowIndicator(row)  
    • BillSimpson's avatar
      BillSimpson
      Occasional Contributor

      Hi

       

      Thanks for this solution as it works for the test I was putting together around Infragistics XamDataGrid..