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 获取或设置当前可见视图顶部行号、左边位置

  • 相关阅读:
    图解隐马尔科夫模型【会其意】
    基于mysql对mybatis中的foreach进行深入研究
    JS-安全检测JavaScript基本数据类型和内置对象的方法
    Java-生成指定长度验证码的一种简单思路
    jQuery-表单流程导航
    JS-获取URL请求参数
    AngularJS-Uncaught Error: [$injector:modulerr]
    AngularJS-系统代码的配置和翻译
    JS-改变页面的颜色之变化核心-获取六位的随机数
    JS-为金额添加千分位逗号分割符
  • 原文地址:https://www.cnblogs.com/karkash/p/3104216.html
Copyright © 2011-2022 走看看