zoukankan      html  css  js  c++  java
  • cxGrid 知识点

    • cxGrid 知识点

      • 设置 TableView.OptionsView.HeaderAutoHeight 为 True 时栏目标题高度自动调整
      • 网格上选择了记录,当焦点移走时,看不到选择的记录,解决办法:修改 TableView 的属性,OptionsSelection->HideSelection 设为 False
      • 遍历选中记录:
        with ATableView.DataController do
        begin
        VOldFocusedRecordIndex := FocusedRecordIndex;

         

        for VIndex := 0 to ATableView.Controller.SelectedRowCount - 1 do
        begin
        FocusedRecordIndex := ATableView.Controller.SelectedRows[VIndex].RecordIndex;
        AQry.UpdateObject.ExecSQL(ukInsert);
        end;

        FocusedRecordIndex := VOldFocusedRecordIndex;
        end;

      • 遍历当前视图所有记录:
        with ATableView.DataController do
        begin
        VOldFocusedRecordIndex := FocusedRecordIndex;

         

        for VIndex := 0 to FilteredRecordCount - 1 do
        begin
        FocusedRecordIndex := FilteredRecordIndex[VIndex];
        AQry.UpdateObject.ExecSQL(ukInsert);
        end;

        FocusedRecordIndex := VOldFocusedRecordIndex;
        end;

      • 调用 TableView 的 DataController.Groups.FullExpand 方法展开所有节点
      • 在使用自定义数据源,删除记录时,先 BeginUpdate,处理完后再 EndUpdate,否则会偶尔抛出索引超出范围:
        tvProducePlan.BeginUpdate;
        try
        FCustomDataSource.DeleteSelectedRecord(GetSelectedIds);
        finally
        tvProducePlan.EndUpdate;
        end;
      • 获取选中记录某列的值:
        function TMainForm.GetSelectedIds: TStringArray;
        var
        VIndex: Integer;
        begin
        SetLength(Result, tvProducePlan.Controller.SelectedRowCount);
        for VIndex := 0 to tvProducePlan.Controller.SelectedRowCount - 1 do
        Result[VIndex]:= tvProducePlan.DataController.Values[tvProducePlan.Controller.SelectedRecords[VIndex].RecordIndex, 0];
        end;
      • 根据某网格的数据定位另一个网格:
        procedure TMainForm.LinkFocusRecord(AParentColumn, AChildColumn: TcxGridColumn; AParentGrid, AChildGrid: TcxGridTableView);
        var
        VIndex: Integer;
        VValue: STring;
        FocusedRecord: TcxGridFocusedRecordChangedEvent;
        begin
        FocusedRecord:= AParentGrid.OnFocusedRecordChanged;
        AParentGrid.OnFocusedRecordChanged := nil;
        try
        with AChildGrid.DataController do
        begin
        VValue := GetDisplayText(FocusedRecordIndex, AChildColumn.Index);
        end;

         

        VIndex := AParentGrid.DataController.FindRecordIndexByText(0, AParentColumn.Index, VValue, False, False, True);

        if VIndex < 0 then
        begin
        AParentGrid.DataController.ClearSelection;
        Exit;
        end;

        AParentGrid.DataController.FocusedRecordIndex := VIndex;
        AParentGrid.DataController.SyncSelectionFocusedRecord;
        finally
        AParentGrid.OnFocusedRecordChanged := FocusedRecord;
        end;
        end;

      • TableView 的 FocusedRecordChanged 事件表示当前聚焦记录改变
      • 使用 TcxGridTableView.Controller 的 TopRowIndex、LeftPos 获取或设置当前可见视图顶部行号、左边位置

  • 相关阅读:
    Python基础检测:20171105
    Python中斐波那契数列的四种写法
    Python中斐波那契数列的四种写法
    学习Python3:20171031
    学习Python3:20171031
    9.3 Trains and Evaluates the MNIST network using a feed dictionary
    9.3 Trains and Evaluates the MNIST network using a feed dictionary
    学习Python3:201701030
    学习Python3:201701030
    周末微光
  • 原文地址:https://www.cnblogs.com/karkash/p/3104216.html
Copyright © 2011-2022 走看看