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/UItemEdit.pas

    r21 r22  
    2828  public
    2929    Report: TReport;
    30     ControlList: TListObject;
    3130    procedure BuildControls;
    3231  end;
     
    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.Update(MainForm.SelectedObject.Table, Data,
    66       '`Id` = ' + IntToStr(MainForm.SelectedItem), MainForm.SelectedObject.Schema);
     67      '`' + MainForm.SelectedObject.PrimaryKey + '` = ' + IntToStr(MainForm.SelectedItem), MainForm.SelectedObject.Schema);
    6768  finally
    6869    Data.Free;
     
    8586  Report := TReport.Create;
    8687  Report.Base := Core.System;
    87   ControlList := TListObject.Create;
    88   ControlList.OwnsObjects := False;
    8988end;
    9089
    9190procedure TItemEditForm.FormDestroy(Sender: TObject);
    9291begin
    93   ControlList.Free;
    9492  Report.Free;
    9593end;
     
    141139        NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    142140        NewControl.Width := (Width div ColumnCount) div 2 - 20;
    143         ControlList.Add(NewControl);
     141        TReportColumn(Report.Columns[I]).Control := NewControl;
    144142
    145143        Column := (Column + 1) mod 2;
    146144        if Column = 0 then LastTop := LastTop + NewControl.Height + 4;
    147145      end;
    148    end else ControlList.Add(nil);
     146   end;
    149147end;
    150148
Note: See TracChangeset for help on using the changeset viewer.