cxGrid 知识点

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
  • 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 获取或设置当前可见视图顶部行号、左边位置
阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6