114 lines
3.1 KiB
ObjectPascal
114 lines
3.1 KiB
ObjectPascal
|
|
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;
|
|||
|
|
|
|||
|
|
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<EFBFBD>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.
|