Ignore:
Timestamp:
Jun 16, 2011, 12:18:21 PM (13 years ago)
Author:
george
Message:
  • Modified: Optimalized reloading of columns list in item list.
  • Fixed: Add and modify function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UItemAdd.pas

    r21 r22  
    2929  public
    3030    Report: TReport;
    31     ControlList: TListObject;
    32   end;
     31  end;
    3332
    3433var
     
    5958    Data := TDictionaryStringString.Create;
    6059    for I := 0 to Report.Columns.Count - 1 do
    61     if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin
     60    if not (TReportColumn(Report.Columns[I]).CustomType is TDataTypeRelationMany) then
     61    if TReportColumn(Report.Columns[I]).ColumnName <> MainForm.SelectedObject.PrimaryKey then begin
    6262      DataType := TReportColumn(Report.Columns[I]).CustomType;
    63       Data.Add(TReportColumn(Report.Columns[I]).ColumnName, DataType.GetControlValue(TWinControl(ControlList[I])));
     63      Data.Add(TReportColumn(Report.Columns[I]).ColumnName,
     64        DataType.GetControlValue(TWinControl(TReportColumn(Report.Columns[I]).Control)));
    6465    end;
    6566    Database.Insert(MainForm.SelectedObject.Table, Data, MainForm.SelectedObject.Schema);
     
    8182  Report := TReport.Create;
    8283  Report.Base := Core.System;
    83   ControlList := TListObject.Create;
    84   ControlList.OwnsObjects := False;
    8584end;
    8685
     
    8887begin
    8988  Report.Free;
    90   ControlList.Free;
    9189end;
    9290
     
    119117
    120118  // Load column names
    121   ControlList.Clear;
    122119    for I := 0 to Report.Columns.Count - 1 do
    123120    if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin
     
    138135        NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    139136        NewControl.Width := (Width div ColumnCount) div 2 - 20;
    140         ControlList.Add(NewControl);
     137        TReportColumn(Report.Columns[I]).Control := NewControl;
    141138
    142139        Column := (Column + 1) mod 2;
    143140        if Column = 0 then LastTop := LastTop + NewControl.Height + 4;
    144141      end;
    145     end else ControlList.Add(nil);
     142    end;
    146143end;
    147144
Note: See TracChangeset for help on using the changeset viewer.