unit uViewFiltrosStock; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxLayoutControl, cxControls, uViewControlGrid, cxGraphics, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage, DB, cxDBData, cxGridLevel, cxClasses, cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, cxCheckComboBox, StdCtrls, Mask, JvExMask, JvToolEdit, JvCombobox; type IViewFiltrosStock = interface ['{ABC745C3-64F0-44E4-AF4B-118AE5060150}'] procedure SetFocusedView (const Value : TcxGridDBTableView); function GetFocusedView : TcxGridDBTableView; property FocusedView : TcxGridDBTableView read GetFocusedView write SetFocusedView; procedure Refresh; end; TfrViewFiltrosStock = class(TFrame, IViewFiltrosStock) dxLayoutControl1Group_Root: TdxLayoutGroup; dxLayoutControl1: TdxLayoutControl; cbColeccion: TcxComboBox; dxLayoutControl1Item1: TdxLayoutItem; dxLayoutControl1Item3: TdxLayoutItem; ccbCentro: TJvCheckedComboBox; private FFocusedView : TcxGridDBTableView; function GetFilterValueList(AColumnIndex: Integer): TStringList; protected procedure RellenarFiltros; procedure SetFocusedView (const Value : TcxGridDBTableView); function GetFocusedView : TcxGridDBTableView; public CentroColumnIndex : Integer; ColeccionColumnIndex : Integer; property FocusedView : TcxGridDBTableView read GetFocusedView write SetFocusedView; procedure Refresh; end; implementation {$R *.dfm} { TfrViewFiltrosStock } function TfrViewFiltrosStock.GetFilterValueList(AColumnIndex: Integer): TStringList; var AValueList : TcxDataFilterValueList; i : Integer; begin Result := TStringList.Create; if AColumnIndex < 0 then Exit; AValueList := TcxDataFilterValueList.Create(FFocusedView.DataController.Filter); try AValueList.Load(AColumnIndex); for i := 0 to AValueList.Count - 1 do Result.Add(AValueList[i].DisplayText); finally FreeAndNil(AValueList); end; end; function TfrViewFiltrosStock.GetFocusedView: TcxGridDBTableView; begin Result := FFocusedView; end; procedure TfrViewFiltrosStock.Refresh; begin inherited; RellenarFiltros; end; procedure TfrViewFiltrosStock.RellenarFiltros; begin if ColeccionColumnIndex >= 0 then with cbColeccion.Properties do begin Items.Clear; Items.AddStrings(GetFilterValueList(ColeccionColumnIndex)); Items.Delete(1); Items.Strings[0] := 'Todos'; cbColeccion.Text := 'Todos'; end; if CentroColumnIndex >= 0 then with ccbCentro do begin Items.Clear; Items.AddStrings(GetFilterValueList(CentroColumnIndex)); Items.Delete(1); Items.Strings[0] := 'Todos'; Checked[0] := True; end; end; procedure TfrViewFiltrosStock.SetFocusedView( const Value: TcxGridDBTableView); begin FFocusedView := Value; end; end.