Forum Discussion

ajohnson2020's avatar
ajohnson2020
Contributor
13 years ago

Comparison of DevEx TcxDBTreeList?

Does anyone have any tips on comparing contents of a DevEx tree, specifically TcxDBTreeList and TcxTreeList from ExpressQuantumGrid?

I've been doing this with simple region comparisons, but they are limited and fragile, and I would like to get away from that if possible.  I already do data checks on our DevEx tables.

I've checked the Help entry for the example on retrieving data from trees, but it's talking about Win32TreeView trees, the DevEx trees seem to be more difficult to dig the data out of.

If I can get that far, I'd also like to be able to limit what data columns are retrieved or at least checked.

I'm running TC 9.2, with debug enabled.



Thanks.

Allen
  • I figured it out, in case anyone else needs to know.  It is necessary to iterate through the row count of each tree level, checking the row count on the child views of each row and recursively going into them to retrieve the data.  Code follows.



    I haven't implemented data column restrictions yet, but that shouldn't be too difficult now that I've gotten this far.



    Thanks.

    Allen




    procedure SaveTcxDBTree(TreeObject, oFile: OleVariant);


    var rowloop, columnloop: integer;


        rowstring, separator: string;


    begin


      // Iterate through each row of the top level of the tree


      separator := '|';


      for rowloop := 0 to TreeObject.wRowCount-1 do


      begin


         


        rowstring := '';


        for columnloop := 0 to TreeObject.wColumnCount-1 do


        begin


          rowstring := rowstring + separator + VarToStr(TreeObject.wValue(rowloop, columnloop))


        end;


        oFile.Write(rowstring + #13#10);


        


        // If this row has a child view with a one or more rows, call the same proc with the child


        if TreeObject.wChildView(rowloop).wRowCount > 0 then


        begin


          SaveTcxDBTree(TreeObject.wChildView(rowloop), oFile);


        end;


      end; 


      


    end;


     


    procedure WriteTreeToFile(TreeObject: OleVariant);


    var inputstr, oFile;


    begin


      oFile := aqFile.OpenTextFile('C:\temp\output.txt', aqFile.faWrite, aqFile.ctANSI, true);


      oFile.Write(inputstr);


      SaveTcxDBTree(TreeObject, oFile);


      oFile.Close;


    end;