Forum Discussion

gus's avatar
gus
Contributor
9 years ago

Custom mapped object seems to refer to wrong object

Hi,

 

I have a complex grid on the rows of which various operations should be performed. One of the specifics of the grid is that it's rows are created lazy and re-used several times, so, say the grid is called myGrid, then myGrid.Rows[i] would return a row which can be the first, second, ... or the last as visible to the user.

 

The grid rows, however, have a property called OriginalNumber, which corresponds to their "logical" number, what a user would expect: the topmost row has an OriginalNumber of 0, the second has 1 and so on. If I want to select the row the row head of which reads 23, I need to find the row with OriginalNumber of 22.

 

To be able to work efficiently with various rows of the grid, I created a custom mapping based on one of the rows (TranslationRowControl class). I've customized identifier properties as follows:

  • ClrFullClassName: Foo.Translation.TranslationRowControl
  • OriginalNumber: 2 (Project Variable, RowOfInterest)

That is, Aliases.Foo.Translation.TranslationRowControl should always refer to the row the OriginalNumber of whic is equal to the value of the project-level variable RowOfInterest.

 

The problem is that this seems not working. When

  • The value of Project.Variables.RowOfInterest is 2 (set in a Jscript function); and
  • The name mapping editor (when pausing execution to debug script) shows the following for OriginalNumber: 2 (Project Variable, RowOfInterest)

-- then Aliases.Foo.Translation.TranslationRowControl.OriginalNumber equals to 0 in the watch window, and if I call, for example, the Click() method of Aliases.Foo.Translation.TranslationRowControl, TC will really click the 1st row instead of the 3rd.

 

What may cause this unexpected behavior? Am I using identifier properties in name mappings for some wrong purposes?

 

  • Are you calling

    Aliases.RefreshMappingInfo();

     

    after changing the Project.Variable?

  • NisHera's avatar
    NisHera
    Valued Contributor

    You can only map objects
    it seems "TranslationRowControl class" is an abstract class of a child of grid.
    can you focus to that row using object spy?

     

    You can read 23rd row to make sure "original number is 22"
    and may have to handle situation of, if any original number is missing

    • gus's avatar
      gus
      Contributor

      Hi,

       

      Actually it is an object, and if the grid is open in the tested app, I can highlight the correct row from both the object browser, both the name mapping editor. Actually row objects are generated using the naming pattern TranslationRowControl , TranslationRowControl1, TranslationRowControl2 and so on -- but, e.g. TranslationRowControl2 may refer to any of the rows in the grid, and the OriginalNumber will tell which row is it.

       

      I have 50 rows in the grid, and I'm trying to access rows with OriginalNumber of 2 to 10.

      • tonydugay's avatar
        tonydugay
        Contributor

        Are you calling

        Aliases.RefreshMappingInfo();

         

        after changing the Project.Variable?