FastReport now can set DisplayLabel :)

freeman35

Местный
Регистрация
26 Июн 2009
Сообщения
14
Реакции
10
Credits
33
You can modify fastreport original code but its your problem. Before chanage code TAKE BACKUP Don't ask me any problem.
I hope fastreport owner add this code modification them source, or we have to change again every updates:)

I wrote class names and pas file names

Код:
//frxReg.pas 
//procedure Register; 
// old line SplashScreenServices.AddPluginBitmap('Fast Report 4',
//RAD splash screen show full version number
   SplashScreenServices.AddPluginBitmap('Fast Report '+{$I frxVersion.inc},

Код:
////frxClass.pas 
YOU HAVE TO WRITE PLACE
//Class is...
{$ELSE}
  TfrxDataSet = class(TfrxDialogComponent)
{$ENDIF}
.......
public//important
   procedure GetFieldDisplayLabelList(List: TStrings); virtual;//After add this line and press "Shift + Ctrl + C" IDE code complete or add maual   
..........   
//Added procedure has to be like this
procedure TfrxDataSet.GetFieldDisplayLabelList(List: TStrings);
begin
   List.Clear;
end;


Код:
// frxDBSet.pas 
//class name is
type
  TfrxDBDataset = class(TfrxCustomDBDataset)
.......
public//important
  procedure GetFieldDisplayLabelList(List: TStrings); override;//Will override before code
.....
procedure TfrxDBDataset.GetFieldDisplayLabelList(List: TStrings);
var i: Integer;
    S: string;
begin
  List.Clear;
  if FieldAliases.Count = 0 then begin
    try
      if FDS <> nil then begin
        List.BeginUpdate;
          for i := 0 to FDS.Fields.Count - 1 do begin
            S := FDS.Fields[i].FieldName+'='+FDS.Fields[i].DisplayLabel;//I want what I added
            if not FDS.Fields[i].Visible then S := '-'+S;//I dont want set again un visible fields. TFields has all detail info why I change again
            List.Add(S);
          end;
        List.EndUpdate;
      end;
    except
    end;
  end else begin
    for i := 0 to FieldAliases.Count - 1 do
      if Pos('-', FieldAliases.Names[i]) <> 1 then
        List.Add(FieldAliases.Values[FieldAliases.Names[i]]);
  end;
end;

And last change. Find this button click and change like this code or can copy+paste on
In my mind, Reset mean set all to default, Update mean update :)so when I click update button after this my code modification everything work normal :)
Код:
// frxEditAliases.pas 

procedure TfrxAliasesEditorForm.UpdateBClick(Sender: TObject);
var
  i: Integer;
  l1, l2: TStrings;
begin
  l1 := TStringList.Create;
  l2 := TStringList.Create;
  l1.Assign(FDataSet.FieldAliases);
  try
    { clear aliases to get real field names }
    FDataSet.FieldAliases.Clear;
    FDataSet.GetFieldList(l2);
  finally
    { set aliases back }
//    FDataSet.FieldAliases.Assign(l1);
   FDataSet.GetFieldDisplayLabelList(L1);
  end;
  for i := 0 to l2.Count - 1 do
    if l1.IndexOfName(l2[i]) = -1 then
      l2[i] := l2[i] + '=' + l2[i]
    else
      l2[i] := l2[i] + '=' + l1.Values[l2[i]];
//  BuildAliasList(l2);
  BuildAliasList(l1);
  l1.Free;
  l2.Free;
end;

Don't forget built component again, (if I were you built all) or just frxDBxx.dpk and frxx.dpk (xx mean delphi version)
If you like my codes show me, and click "THANKS" button please :)