Forum Discussion

Angshuman's avatar
Angshuman
Occasional Contributor
14 years ago

Problem with XCeed Datagrid

I am trying to read the values in the cells of an XCeed datagrid (basically, the control I am using is one that is derived from it). Please take a look at the attached image to get the object hierarchy I am looking at.



I am trying to locate a cell in the following ways, but none of them works:

------------------------------------------

var IE,AllServicesCard,tableControl;

  var RowNum = 2;

  var ColNum = 1;

  PropArray = new Array("ClrClassName", "WPFControlOrdinalNo");

  ValuesArray = new Array("DataRow", 1);



  IE = Aliases.iexplore;

  AllServicesCard = IE.Find("ClrClassName","AllServicesCardMainPage",20);  

  LogInfo(AllServicesCard);  

  tableControl = AllServicesCard.tableControl;

  var Row;

  Row = tableControl.WPFObject("DataRow","",RowNum);

  //Row = tableControl.Find(PropArray, ValuesArray, 5);

  var Col = Row.WPFObject("DataCell","",ColNum);

  var caption = Col.WPFControlText;

----------------------------------------------------------------



As you can see, I am trying out both the 'Find' method and the WPFObject route, but none of them works. The error I get is like 'the object doesn't support the property or method'.



Please help.



Thanks in advance.

3 Replies

  • Angshuman's avatar
    Angshuman
    Occasional Contributor
    Well, after a few trials I replaced



    tableControl = AllServicesCard.tableControl;



    with



    tableControl = AllServicesCard.FindChild("ClrClassName","TableControl",2);



    and things seem working, but I have no clue how the objects in each of the two cases are different!
  • Angshuman's avatar
    Angshuman
    Occasional Contributor
    There is one more issue - I try to create a generic function which would accept the row and column index and return the text displayed on the cell. I came up with



    function  GetTableControlCellValue(TableControl,RowNum,ColNum)

    {

       PropArray = new Array("ClrClassName", "WPFControlOrdinalNo");

       ValuesArray = new Array("DataRow", RowNum);

       var Row = TableControl.WPFObject("DataRow","",RowNum);  

       PropArray = new Array("ClrClassName", "WPFControlOrdinalNo");

       ValuesArray = new Array("DataCell", ColNum);

       var Col = Row.FindChild(PropArray, ValuesArray, 5);

       return Col.WPFControlText;

    }



    This works ONLY IF I don't rearrange the rows (by sorting) or columns (by dragging the column headers and repositioning them). How to overcome this issue - i.e. have a way to get me the cell text even if the table  rows and columns are reordered?

  • Hi,







    I have no clue how the objects in each of the two cases are different



    In the first variant, the needed property is a child of AllServicesCard, and in the second variant, you use the FindChild method searching for the needed property among children, grandchildren, and great grandchildren. It seems that the property is not a child, but a grandchild or a great grandchild - that is why, your new code can find the object, while the original code can't do it.







    This works ONLY IF I don't rearrange the rows (by sorting) or columns (by dragging the column headers and repositioning them). How to overcome this issue - i.e. have a way to get me the cell text even if the table  rows and columns are reordered?



    We have failed to reproduce the problem: reordering rows and columns does not make the function work incorrectly. Try refreshing the objects tree from your script: add the following line at the beginning of the GetTableControlCellValue function:







      Aliases.iexplore.Refresh();







    If it does not help, please clarify exactly what works incorrectly in the function and send us your project suite along with the failed execution logs.