Jump to content

Filter uniDbGrid runTime


TI.ME

Recommended Posts

Good Morning!!!

I'm creating a Filter option in uniDbGrid in runtime ...

All component connections ...

The visual display is perfect, but the filter code does not work.

When I type the letter no, the event is triggered but the value of the second letter on, the event is not even triggered !!!

I have a project ready but I do not know how to attach in the forum !!!

Could you guide me ???

Unigui Version 1.10.0 Build 1469

 

 

 

Code Customer...

 

 

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  oHidePanel : TUniHiddenPanel;
  oEdit : array of TUniEdit;
  i : integer;
begin
  TUniHiddenPanel(oHidePanel) := TUniHiddenPanel.Create(Self);
 
  for I := 0 to Pred(UniDBGrid1.Columns.Count) do
  begin
    SetLength(oEdit,Length(oEdit)+1);
    TUniEdit(oEdit)        := TUniEdit.Create(Self);
    TUniEdit(oEdit).Parent := TUniHiddenPanel(oHidePanel).Parent;
    TUniEdit(oEdit).Width  := UniDBGrid1.Columns.Items.Width - 10;
    TUniEdit(oEdit).Name   := 'Edit_'+IntToStr(i);
    UniDBGrid1.Columns.Items.Filtering.Enabled := True;
    UniDBGrid1.Columns.Items.Filtering.Editor  := TUniEdit(oEdit);
  end;
 
  UniMainModule.ADOQuery1.Open;
  UniMainModule.ADOQuery2.Open;
end;
Link to comment
Share on other sites

 

Good Morning!!!

 

I'm creating a Filter option in uniDbGrid in runtime ...

 

All component connections ...

 

The visual display is perfect, but the filter code does not work.

 

When I type the letter no, the event is triggered but the value of the second letter on, the event is not even triggered !!!

 

I have a project ready but I do not know how to attach in the forum !!!

 

Could you guide me ???

 

Unigui Version 1.10.0 Build 1469

 

 

 

Code Customer...

 

 

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  oHidePanel : TUniHiddenPanel;
  oEdit : array of TUniEdit;
  i : integer;
begin
  TUniHiddenPanel(oHidePanel) := TUniHiddenPanel.Create(Self);
 
  for I := 0 to Pred(UniDBGrid1.Columns.Count) do
  begin
    SetLength(oEdit,Length(oEdit)+1);
    TUniEdit(oEdit)        := TUniEdit.Create(Self);
    TUniEdit(oEdit).Parent := TUniHiddenPanel(oHidePanel).Parent;
    TUniEdit(oEdit).Width  := UniDBGrid1.Columns.Items.Width - 10;
    TUniEdit(oEdit).Name   := 'Edit_'+IntToStr(i);
    UniDBGrid1.Columns.Items.Filtering.Enabled := True;
    UniDBGrid1.Columns.Items.Filtering.Editor  := TUniEdit(oEdit);
  end;
 
  UniMainModule.ADOQuery1.Open;
  UniMainModule.ADOQuery2.Open;
end;

 

 

tente assim:

 

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  oHidePanel : TUniHiddenPanel;
  oEdit : array of TUniEdit;
  i : integer;
begin
  oHidePanel := TUniHiddenPanel.Create(Self);
  oHidePanel.Parent := self;
  self.InsertControl(oHidePanel);
 
  for I := 0 to Pred(UniDBGrid1.Columns.Count) do
  begin
    SetLength(oEdit,Length(oEdit)+1);
    TUniEdit(oEdit)        := TUniEdit.Create(Self);
    TUniEdit(oEdit).Parent := oHidePanel;
    TUniEdit(oEdit).Width  := UniDBGrid1.Columns.Items.Width - 10;
    TUniEdit(oEdit).Name   := 'Edit_'+IntToStr(i);
 
    UniDBGrid1.Columns.Items.Filtering.Enabled := True;
    UniDBGrid1.Columns.Items.Filtering.Editor  := TUniEdit(oEdit);
    UniDBGrid1.Columns.Filtering.ChangeDelay := 250;
  end;
 
  UniMainModule.ADOQuery1.Open;
  UniMainModule.ADOQuery2.Open;
end;
Link to comment
Share on other sites

  • 1 year later...
On 8/23/2018 at 12:19 PM, Hayri ASLAN said:

We have a solution. After adjust email address we will share it.

Hello!! =]

I'm with this exactly problem, i'm creating the filter in runtime and the visual are ok but the event just trigger once and de variable 'value' comes empty.

Link to comment
Share on other sites

15 hours ago, freedowsRoO said:

I modified the grid filter demo to show you the problem.

GridFiltering-2.rar

procedure TMainForm.UniFormCreate(Sender: TObject);
Var
  THidenPanel: TUniHiddenPanel;
  TEdit: TUniEdit;
begin
  UniMainModule.ADOQuery1.Open;
  UniMainModule.ADOQuery2.Open;

  THidenPanel:= TUniHiddenPanel.Create(self);
  THidenPanel.Parent := Self;  //<--------------------
  THidenPanel.Name:= 'THiddenPanel';

  TEdit:= TUniEdit.Create(self);
  TEdit.Parent:= THidenPanel;
  TEdit.Name:= 'TEdit';
  TEdit.EmptyText:= 'teste';

  if Assigned(TEdit) then
  begin
    UniDBGrid1.Columns[3].Filtering.Editor:= TEdit;
    UniDBGrid1.Columns[3].Filtering.Enabled:= True;
  end;

end;

 

  • Like 1
Link to comment
Share on other sites

10 hours ago, Sherzod said:

procedure TMainForm.UniFormCreate(Sender: TObject);
Var
  THidenPanel: TUniHiddenPanel;
  TEdit: TUniEdit;
begin
  UniMainModule.ADOQuery1.Open;
  UniMainModule.ADOQuery2.Open;

  THidenPanel:= TUniHiddenPanel.Create(self);
  THidenPanel.Parent := Self;  //<--------------------
  THidenPanel.Name:= 'THiddenPanel';

  TEdit:= TUniEdit.Create(self);
  TEdit.Parent:= THidenPanel;
  TEdit.Name:= 'TEdit';
  TEdit.EmptyText:= 'teste';

  if Assigned(TEdit) then
  begin
    UniDBGrid1.Columns[3].Filtering.Editor:= TEdit;
    UniDBGrid1.Columns[3].Filtering.Enabled:= True;
  end;

end;

 

It works but when i try to create a grid at runtime it's not work.... anny ideia?

GridFiltering-2.rar

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 months later...

You can use the standard example "GridFiltering-2".

Drop TUniTreeView on UniHiddenPanel1 and press "Run(F9)" with debug. Then open localhost:8077 in browser.

Delphi Rio, UniGUI 1530, Firefox, Win 10 x64.

Screenshot_21.jpg

Link to comment
Share on other sites

  • 1 year later...

//Date: 2021-08-01
//Parm: FEntity.FItems索引
//Desc: 依据nIdx字典项,创建过滤组件
function TBindData.AddFilterCtrl(const nIdx: Integer): TControl;
var nEdit: TUniEdit;
begin
  if not Assigned(FFilterPanel) then
  begin
    FFilterPanel := TUniHiddenPanel.Create(FParentControl);
    FFilterPanel.Parent := FDBGrid.Parent;
    //this needs to have a parent assigned and coexist with the TUniDBGrid
    FFilterPanel.Visible := False;
  end;

  Result := FindFilterCtrl(nIdx);
  if Assigned(Result) then Exit;
  if not FEntity.FItems[nIdx].FQuery then Exit;

  nEdit := TUniEdit.Create(FParentControl);
  with nEdit do
  begin
    Parent := FFilterPanel;
    CharEOL := #13;
    EmptyText := 'search...';

    Tag := nIdx;
    ClearButton := True;
  end;

  Result := nEdit;
end;

Link to comment
Share on other sites

  • 2 years later...
On 11/22/2019 at 10:50 AM, Sherzod said:
procedure TMainForm.UniFormCreate(Sender: TObject);
Var
  THidenPanel: TUniHiddenPanel;
  TEdit: TUniEdit;
begin
  UniMainModule.ADOQuery1.Open;
  UniMainModule.ADOQuery2.Open;

  THidenPanel:= TUniHiddenPanel.Create(self);
  THidenPanel.Parent := Self;  //<--------------------
  THidenPanel.Name:= 'THiddenPanel';

  TEdit:= TUniEdit.Create(self);
  TEdit.Parent:= THidenPanel;
  TEdit.Name:= 'TEdit';
  TEdit.EmptyText:= 'teste';

  if Assigned(TEdit) then
  begin
    UniDBGrid1.Columns[3].Filtering.Editor:= TEdit;
    UniDBGrid1.Columns[3].Filtering.Enabled:= True;
  end;

end;

 

@Sherzodдобрый день. Подскажите а высвобождение объекта TEdit происходит автоматически после уничтожения грида? или надо тоже вручную?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...