This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
LuisLeon_FactuGES2/Source/Modulos/Informes base/Views/uViewColumnas.pas

115 lines
3.1 KiB
ObjectPascal
Raw Permalink Blame History

unit uViewColumnas;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, dxLayoutControl, cxControls, cxContainer, cxListBox,
TBXDkPanels, ActnList, cxCustomData, cxGridDBTableView, cxGridTableView,
JvExControls, JvComponent, JvxCheckListBox, uViewInformeBaseGrid,
cxCheckListBox, cxCheckBox, uViewInformeBaseParametros, cxLookAndFeelPainters;
type
IViewColumnas = interface(IViewInformeBaseParametros)
['{A7072B8B-5AC1-4AC4-BD58-F03B96FFEA4B}']
function GetCheckedColumns : TStringList;
end;
TfrViewColumnas = class(TfrViewInformeBaseParametros, IViewColumnas)
lbColumnas: TcxCheckListBox;
TBXLabel1: TTBXLabel;
procedure lbColumnasClickCheck(Sender: TObject; AIndex: Integer;
APrevState, ANewState: TcxCheckBoxState);
protected
procedure RellenarListaColumnas;
procedure SetModificable(const Value : Boolean); override;
public
procedure Refresh; override;
procedure Execute; override;
function GetCheckedColumns : TStringList;
end;
implementation
{$R *.dfm}
{ TfrViewColumnas }
procedure TfrViewColumnas.Refresh;
begin
inherited;
RellenarListaColumnas;
end;
procedure TfrViewColumnas.RellenarListaColumnas;
var
i : integer;
AIndex : Integer;
begin
with lbColumnas do
begin
Items.BeginUpdate;
Items.Clear;
try
for i := 0 to ViewInformeBaseGrid.ColumnCount - 1 do
begin
AddItem(ViewInformeBaseGrid.Columns[i].Caption);
AIndex := Items.Count - 1;
Items[AIndex].Checked := ViewInformeBaseGrid.Columns[i].Visible;
Items[AIndex].ItemObject := ViewInformeBaseGrid.Columns[i];
end;
finally
Items.EndUpdate;
end;
end;
end;
procedure TfrViewColumnas.lbColumnasClickCheck(Sender: TObject;
AIndex: Integer; APrevState, ANewState: TcxCheckBoxState);
var
i : integer;
begin
inherited;
{ No hacer nada por que el cambio en las columnas se debe ver cuando
el usuario pulse sobre el bot<6F>n 'Refrescar'. }
{ with lbColumnas.Items[AIndex] do
if Assigned(ItemObject) then
(ItemObject as TcxGridDBColumn).Visible := (ANewState = cbsChecked);}
end;
procedure TfrViewColumnas.Execute;
var
AIndex : integer;
begin
inherited;
for AIndex := 0 to lbColumnas.Items.Count - 1 do
with lbColumnas.Items[AIndex] do
if Assigned(ItemObject) then
(ItemObject as TcxGridDBColumn).Visible := (State = cbsChecked);
end;
function TfrViewColumnas.GetCheckedColumns: TStringList;
var
AIndex : integer;
begin
result := TStringList.Create;
for AIndex := 0 to lbColumnas.Items.Count - 1 do
if (lbColumnas.Items[AIndex].State = cbsChecked) then
with lbColumnas.Items[AIndex] do
if Assigned(ItemObject) then
Result.Add((ItemObject as TcxGridDBColumn).DataBinding.FieldName);
end;
procedure TfrViewColumnas.SetModificable(const Value: Boolean);
begin
inherited;
lbColumnas.ReadOnly := not Value;
if lbColumnas.ReadOnly then
lbColumnas.Style.TextColor := clBtnShadow
else
lbColumnas.Style.TextColor := clWindowText;
end;
end.