|
@@ -154,7 +154,7 @@ uses
|
|
|
|
|
|
{ TVisualGridOptions }
|
|
{ TVisualGridOptions }
|
|
|
|
|
|
- TVisualGridOptions = set of (vgoColAutoFill, vgoColSizing, vgoAutoHidePaging, vgoMultiSearchCheckComboBox, vgoSortDirectionAllowNone);
|
|
|
|
|
|
+ TVisualGridOptions = set of (vgoColAutoFill, vgoColSizing, vgoAutoHidePaging, vgoAutoHideSearchPanel, vgoMultiSearchCheckComboBox, vgoSortDirectionAllowNone);
|
|
|
|
|
|
{ TSortMode }
|
|
{ TSortMode }
|
|
|
|
|
|
@@ -1812,10 +1812,12 @@ procedure TCustomVisualGrid.SetOptions(AValue: TVisualGridOptions);
|
|
var
|
|
var
|
|
LSortDirectionAllowNone: boolean;
|
|
LSortDirectionAllowNone: boolean;
|
|
LAutoHidePaging: boolean;
|
|
LAutoHidePaging: boolean;
|
|
|
|
+ LAutoHideSearchPanel: boolean;
|
|
begin
|
|
begin
|
|
if FOptions=AValue then Exit;
|
|
if FOptions=AValue then Exit;
|
|
LSortDirectionAllowNone := vgoSortDirectionAllowNone in FOptions;
|
|
LSortDirectionAllowNone := vgoSortDirectionAllowNone in FOptions;
|
|
LAutoHidePaging := vgoAutoHidePaging in FOptions;
|
|
LAutoHidePaging := vgoAutoHidePaging in FOptions;
|
|
|
|
+ LAutoHideSearchPanel := vgoAutoHideSearchPanel in FOptions;
|
|
|
|
|
|
FOptions:=AValue;
|
|
FOptions:=AValue;
|
|
if vgoColSizing in FOptions then
|
|
if vgoColSizing in FOptions then
|
|
@@ -1829,8 +1831,8 @@ begin
|
|
// refresh for sort direction graphic
|
|
// refresh for sort direction graphic
|
|
if LSortDirectionAllowNone <> (vgoSortDirectionAllowNone in AValue) then
|
|
if LSortDirectionAllowNone <> (vgoSortDirectionAllowNone in AValue) then
|
|
SortDirectionGlyphRefresh;
|
|
SortDirectionGlyphRefresh;
|
|
- // try to hide paging panel
|
|
|
|
- if LAutoHidePaging <> (vgoAutoHidePaging in AValue) then
|
|
|
|
|
|
+ // try to hide paging panel or search panel
|
|
|
|
+ if (LAutoHidePaging <> (vgoAutoHidePaging in AValue)) or (LAutoHideSearchPanel <> (vgoAutoHideSearchPanel in AValue)) then
|
|
RefreshPageIndexAndGridInterface;
|
|
RefreshPageIndexAndGridInterface;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1973,8 +1975,20 @@ end;
|
|
|
|
|
|
procedure TCustomVisualGrid.RefreshPageIndexAndGridInterface;
|
|
procedure TCustomVisualGrid.RefreshPageIndexAndGridInterface;
|
|
var
|
|
var
|
|
- LCountOnPage2, LCount: Integer;
|
|
|
|
- LGridUnusedHeight: integer;
|
|
|
|
|
|
+ LCountOnPage2: Integer;
|
|
|
|
+ LGridUnusedHeight, LPotentialHeight: integer;
|
|
|
|
+ LWasVisible: boolean;
|
|
|
|
+
|
|
|
|
+ function RecalcPageCount: boolean;
|
|
|
|
+ var
|
|
|
|
+ LCount: Integer;
|
|
|
|
+ begin
|
|
|
|
+ LCount := ClientRowCount;
|
|
|
|
+ Result := LCount <> PageSize;
|
|
|
|
+ if Result then
|
|
|
|
+ PageSize := LCount;
|
|
|
|
+ end;
|
|
|
|
+
|
|
begin
|
|
begin
|
|
SetPageIndexEditText(IntToStr(Succ(FPageIndex)));
|
|
SetPageIndexEditText(IntToStr(Succ(FPageIndex)));
|
|
FPageCountLabel.Caption := Format('/%d',[FPageCount]);
|
|
FPageCountLabel.Caption := Format('/%d',[FPageCount]);
|
|
@@ -1991,8 +2005,12 @@ begin
|
|
begin
|
|
begin
|
|
LCountOnPage2 := FTotalDataCount - ClientRowCount;
|
|
LCountOnPage2 := FTotalDataCount - ClientRowCount;
|
|
LGridUnusedHeight := FDrawGrid.ClientHeight - FDrawGrid.GridHeight;
|
|
LGridUnusedHeight := FDrawGrid.ClientHeight - FDrawGrid.GridHeight;
|
|
|
|
+ LPotentialHeight := FBottomPanel.Height + LGridUnusedHeight;
|
|
|
|
+ // vgoAutoHideSearchPanel + AutoPageSize + vgoAutoHidePaging is killer combo :P
|
|
|
|
+ if (vgoAutoHideSearchPanel in FOptions) and FTopPanel.Visible and not Assigned(FWidgetControl) then
|
|
|
|
+ LPotentialHeight := LPotentialHeight + FTopPanel.Height;
|
|
if FBottomPanel.Visible
|
|
if FBottomPanel.Visible
|
|
- and (FDrawGrid.DefaultRowHeight * LCountOnPage2 <= FBottomPanel.Height + LGridUnusedHeight) then
|
|
|
|
|
|
+ and (FDrawGrid.DefaultRowHeight * LCountOnPage2 <= LPotentialHeight) then
|
|
begin
|
|
begin
|
|
FBottomPanel.Visible := False;
|
|
FBottomPanel.Visible := False;
|
|
PageSize := PageSize + LCountOnPage2;
|
|
PageSize := PageSize + LCountOnPage2;
|
|
@@ -2002,19 +2020,42 @@ begin
|
|
if FCanPage then
|
|
if FCanPage then
|
|
begin
|
|
begin
|
|
FBottomPanel.Visible := true;
|
|
FBottomPanel.Visible := true;
|
|
- LCount := ClientRowCount;
|
|
|
|
- if LCount <> PageSize then
|
|
|
|
- begin
|
|
|
|
- PageSize := LCount;
|
|
|
|
|
|
+ if RecalcPageCount then
|
|
Exit;
|
|
Exit;
|
|
- end;
|
|
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end else
|
|
end else
|
|
FBottomPanel.Visible := FCanPage
|
|
FBottomPanel.Visible := FCanPage
|
|
end
|
|
end
|
|
else
|
|
else
|
|
|
|
+ begin
|
|
|
|
+ LWasVisible := FBottomPanel.Visible;
|
|
FBottomPanel.Visible := FCanPage;
|
|
FBottomPanel.Visible := FCanPage;
|
|
|
|
+ if (FTopPanel.Visible <> LWasVisible) and RecalcPageCount then
|
|
|
|
+ Exit;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ // show or hide Search Panel (related to option vgoAutoHideSearchPanel)
|
|
|
|
+ if (vgoAutoHideSearchPanel in FOptions) and (FPageCount in [0,1]) then
|
|
|
|
+ begin
|
|
|
|
+ if FCanSearch then
|
|
|
|
+ begin
|
|
|
|
+ // if widget control is set, only hide search controls
|
|
|
|
+ LWasVisible := FTopPanel.Visible;
|
|
|
|
+ FTopPanel.Visible := Assigned(FWidgetControl);
|
|
|
|
+ FTopPanelRight.Visible := not Assigned(FWidgetControl);
|
|
|
|
+ if (FTopPanel.Visible <> LWasVisible) and RecalcPageCount then
|
|
|
|
+ Exit;
|
|
|
|
+ end;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ LWasVisible := FTopPanel.Visible;
|
|
|
|
+ FTopPanel.Visible := FCanSearch;
|
|
|
|
+ FTopPanelRight.Visible := true;
|
|
|
|
+ if (FTopPanel.Visible <> LWasVisible) and RecalcPageCount then
|
|
|
|
+ Exit;
|
|
|
|
+ end;
|
|
|
|
|
|
FDrawGrid.Refresh;
|
|
FDrawGrid.Refresh;
|
|
if Assigned(FOnFinishedUpdating) then
|
|
if Assigned(FOnFinishedUpdating) then
|
|
@@ -2341,12 +2382,15 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TCustomVisualGrid.SetWidgetControl(AValue: TControl);
|
|
procedure TCustomVisualGrid.SetWidgetControl(AValue: TControl);
|
|
|
|
+var
|
|
|
|
+ LRefreshPageIndexAndGridInterface: boolean;
|
|
begin
|
|
begin
|
|
if FWidgetControl=AValue then Exit;
|
|
if FWidgetControl=AValue then Exit;
|
|
|
|
|
|
if Assigned(FWidgetControl) then
|
|
if Assigned(FWidgetControl) then
|
|
FWidgetControl.Parent := FWidgetControlParent;
|
|
FWidgetControl.Parent := FWidgetControlParent;
|
|
|
|
|
|
|
|
+ LRefreshPageIndexAndGridInterface := (not Assigned(FWidgetControl) and Assigned(AValue)) or (not Assigned(AValue) and Assigned(FWidgetControl));
|
|
FWidgetControl:=AValue;
|
|
FWidgetControl:=AValue;
|
|
|
|
|
|
if Assigned(AValue) then
|
|
if Assigned(AValue) then
|
|
@@ -2366,6 +2410,9 @@ begin
|
|
end;
|
|
end;
|
|
end else
|
|
end else
|
|
FTopPanelLeft.Width:=0;
|
|
FTopPanelLeft.Width:=0;
|
|
|
|
+
|
|
|
|
+ if LRefreshPageIndexAndGridInterface then
|
|
|
|
+ RefreshPageIndexAndGridInterface;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TCustomVisualGrid.StandardDrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
|
|
procedure TCustomVisualGrid.StandardDrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
|