RxDBGrid - add enable property for RxCollumn filter

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2736 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75 2013-05-08 05:26:49 +00:00
parent 3c8f140dc0
commit e16f5bacfb

View File

@ -294,6 +294,7 @@ type
TRxColumnFilter = class(TPersistent) TRxColumnFilter = class(TPersistent)
private private
FEnabled: boolean;
FOwner: TRxColumn; FOwner: TRxColumn;
FValue: string; FValue: string;
FValueList: TStringList; FValueList: TStringList;
@ -321,6 +322,7 @@ type
property EmptyValue: string read FEmptyValue write FEmptyValue; property EmptyValue: string read FEmptyValue write FEmptyValue;
property EmptyFont: TFont read FEmptyFont write FEmptyFont; property EmptyFont: TFont read FEmptyFont write FEmptyFont;
property ItemIndex: integer read GetItemIndex write SetItemIndex; property ItemIndex: integer read GetItemIndex write SetItemIndex;
property Enabled:boolean read FEnabled write FEnabled default true;
end; end;
{ TRxColumnEditButton } { TRxColumnEditButton }
@ -568,7 +570,7 @@ type
procedure CleanDSEvent; procedure CleanDSEvent;
procedure UpdateRowsHeight; function UpdateRowsHeight:integer;
procedure ResetRowHeght; procedure ResetRowHeght;
procedure DoClearInvalidTitle; procedure DoClearInvalidTitle;
@ -2388,19 +2390,21 @@ begin
FSortingNow:=false; FSortingNow:=false;
end; end;
procedure TRxDBGrid.UpdateRowsHeight; function TRxDBGrid.UpdateRowsHeight: integer;
var var
i, J, H, H1:integer; i, J, H, H1, H2:integer;
B:boolean; B:boolean;
F:TField; F:TField;
S:string; S:string;
CurActiveRecord: Integer; CurActiveRecord: Integer;
R:TRxColumn; R:TRxColumn;
begin begin
Result:=0;
if not (Assigned(DataLink) and DataLink.Active) then if not (Assigned(DataLink) and DataLink.Active) then
exit; exit;
CurActiveRecord:=DataLink.ActiveRecord; CurActiveRecord:=DataLink.ActiveRecord;
H2:=0;
for i:=GCache.VisibleGrid.Top to GCache.VisibleGrid.Bottom do for i:=GCache.VisibleGrid.Top to GCache.VisibleGrid.Bottom do
begin begin
DataLink.ActiveRecord:=i - FixedRows; DataLink.ActiveRecord:=i - FixedRows;
@ -2426,8 +2430,12 @@ begin
end; end;
if i<RowCount then if i<RowCount then
begin
RowHeights[i] := DefaultRowHeight * H; RowHeights[i] := DefaultRowHeight * H;
H2:=H2 + RowHeights[i];
if H2<=ClientHeight then
Inc(Result);
end;
end; end;
DataLink.ActiveRecord:=CurActiveRecord; DataLink.ActiveRecord:=CurActiveRecord;
end; end;
@ -3170,7 +3178,7 @@ begin
if (Cell.Y = 0) and (Cell.X >= Ord(dgIndicator in Options)) and (Rect.Top < Y) then if (Cell.Y = 0) and (Cell.X >= Ord(dgIndicator in Options)) and (Rect.Top < Y) then
begin begin
C:=TRxColumn (Columns[Columns.RealIndex(Cell.x - 1)]); C:=TRxColumn (Columns[Columns.RealIndex(Cell.x - 1)]);
if C.Filter.ValueList.Count > 0 then if (C.Filter.Enabled) and (C.Filter.ValueList.Count > 0) then
begin begin
FFilterListEditor.Style := csDropDownList; FFilterListEditor.Style := csDropDownList;
if C.Filter.DropDownRows>0 then if C.Filter.DropDownRows>0 then
@ -3558,10 +3566,10 @@ end;
procedure TRxDBGrid.UpdateActive; procedure TRxDBGrid.UpdateActive;
begin begin
if FInProcessCalc > 0 then { if FInProcessCalc > 0 then
exit; exit;}
inherited UpdateActive; inherited UpdateActive;
if FInProcessCalc < 0 then { if FInProcessCalc < 0 then
begin begin
FInProcessCalc := 0; FInProcessCalc := 0;
UpdateFooterRowOnUpdateActive; UpdateFooterRowOnUpdateActive;
@ -3569,7 +3577,7 @@ begin
{ else { else
if FFooterOptions.Active and (FFooterOptions.RowCount > 0) then if FFooterOptions.Active and (FFooterOptions.RowCount > 0) then
UpdateFooterRowOnUpdateActive;} UpdateFooterRowOnUpdateActive;}
}
// UpdateRowsHeight; // UpdateRowsHeight;
end; end;
@ -3587,8 +3595,16 @@ begin
end; end;
function TRxDBGrid.GetBufferCount: integer; function TRxDBGrid.GetBufferCount: integer;
var
H:integer;
begin begin
Result := ClientHeight div DefaultRowHeight; Result := ClientHeight div DefaultRowHeight;
if rdgWordWrap in FOptionsRx then
begin
H:=UpdateRowsHeight;
// if H>0 then
// Result := H;
end;
if dgTitles in Options then if dgTitles in Options then
begin begin
Dec(Result, RowHeights[0] div DefaultRowHeight); Dec(Result, RowHeights[0] div DefaultRowHeight);
@ -4105,7 +4121,7 @@ begin
for i := 0 to Columns.Count - 1 do for i := 0 to Columns.Count - 1 do
begin begin
C := TRxColumn(Columns[i]); C := TRxColumn(Columns[i]);
if (C.Field <> nil) and (C.Filter.ValueList.IndexOf(C.Field.DisplayText) < 0) then if C.Filter.Enabled and (C.Field <> nil) and (C.Filter.ValueList.IndexOf(C.Field.DisplayText) < 0) then
C.Filter.ValueList.Add(C.Field.DisplayText); C.Filter.ValueList.Add(C.Field.DisplayText);
end; end;
DataSource.DataSet.Next; DataSource.DataSet.Next;
@ -5203,6 +5219,7 @@ begin
FEmptyFont.Style := [fsItalic]; FEmptyFont.Style := [fsItalic];
FEmptyValue := sRxDBGridEmptiFilter; FEmptyValue := sRxDBGridEmptiFilter;
FEnabled:=true;
end; end;
destructor TRxColumnFilter.Destroy; destructor TRxColumnFilter.Destroy;