如何从第三层取cxgrid 的相应顶层数据?

解决方案 »

  1.   

    第一层 表1(a1,a2,a3,a4,a5,a6,a7)
    第二层 表2(b1,b2,b3,b4,b5,b6,b7)关联一层 a1,a2(表2有a1,a2但不显示)
    第三层 表3(c1,c2,c3,c4,c5,c6,c7)关联二层 b1,b2(表3有b1,b2但不显示)
    在cxgrig 三层全部展开后,焦点在第三层,如何取得第一层相应的a4,a5,a6 的内容
      

  2.   

    每个节点都是可以访问其父节点的,类似parentnode
      

  3.   

    在我的程序中有这么一段,是把合计值转为新的表项目
    PS:只是一段,你单独无法执行procedure TMyAnalyseCxBdTableForm.MyAddMyRecord; var i,j,MyLevel :integer; MyRow:TcxCustomGridRow; MyListA,MyListB:Tstrings;
             s:string;   MyGroupFooter : TcxDataFooterSummaryItems;  AValue: Variant;
             ASummary:TcxDataSummary;
    begin
          if not CreateFieldsFromFooter then exit;
          if not MyCreateCxGrid then exit;
          MyGridView.DataController.Groups.FullExpand;
          MyLevel:=MyGroupLevel;
          MyListA:=TStringList.Create;
          MyListB:=TStringList.Create;
          ASummary:=MyGridView.DataController.Summary;
          MyGroupFooter:=MyGridView.DataController.Summary.FooterSummaryItems;
          MyListB.Clear;
           for i:=0 to MyGridView.GroupedItemCount-1 do
            begin
             MyListB.Add('MyG'+TcxGridDBColumn(MyGridView.GroupedColumns[i]).DataBinding.FieldName+IntToStr(i));
             MyListA.add('值');
            end;
          dxMemData1.Active:=true;
             try
              for   i := 0   to   MyGridView.ViewData.RowCount-1   do
              begin
                   MyRow   :=  MyGridView.ViewData.Rows[i];             if   MyRow  is   TcxGridGroupRow   then
                  begin
                    MyListA.Strings[MyRow.Level]:=TcxGridGroupRow(MyRow).DisplayTexts[0];
                    if MyLevel=MyRow.Level then
                      begin
                        dxMemData1.Append;
                        for j:=0 to MyLevel do
                          dxMemData1.FieldByName(MyListB.Strings[j]).AsString:=MyListA.Strings[j];
                        for j:=0 to  MyGroupFooter.Count-1 do
                          begin
                           if MyGroupFooter[j].Position=spFooter then
                             begin
                            s:='MyR'+TcxGridDBColumn(MyGroupFooter[j].ItemLink).DataBinding.FieldName+IntToStr(j);
                            dxMemData1.FieldByName(s).AsVariant:=ASummary.GroupSummaryDisplayValues[i,MyRow.Level,
                                       ASummary.GroupFooterIndexOfItemLink[MyRow.Level, MyGroupFooter[j].ItemLink  ]];
                             end;
                           end;
                        dxMemData1.Post;
                      end;
                   end ;
              end;
               dxMemData1.First; 
             finally            MyListA.Free;
                MyListB.Free; 
             end;
           MyGridView.DataController.Groups.FullCollapse;
    end;
      

  4.   

    cxGrid2DBBandedTableView1.Controller.FocusedColumn.VisibleCaption;PS:cxGrid2DBBandedTableView1為您的第幾層個cxGrid2DBBandedTableView