Jump to content

How to set Filtering.Editor in UniDBGrid dynamically? [ Solved ]


Fábio Matte

Recommended Posts

Hi,
I'm trying to put the Filtering.Editor option on dynamically created columns in a UniDBGrid, but it doesn't work at all, in all the ways I try, I get the message "Argument out of range" when running.

Here is the code I used to apply the filter:

    dbGridSQL_Resultado.Columns.Clear;

   if optControl = 1 then
   begin
      with dbGridSQL_Resultado do
      begin
        DataSource                          := dsFDMemTable;
        Columns.Items[0].Filtering.Editor   := TUniEdit(Self.FindComponent('UniEdit1').Name);
        Columns.Items[0].Filtering.Enabled  := True;
      end;
   end;

 

Image Error:

image.png.ce2f7183a71ff387d825b5b04a4f9a4f.png

Edited by Fábio Matte
Link to comment
Share on other sites

3 minutes ago, Fábio Matte said:

Oi,
estou tentando colocar a opção Filtragem.Editor em colunas criadas dinamicamente em um UniDBGrid, mas não funciona de jeito nenhum, de todas as maneiras que tento, recebo a mensagem "Argumento fora do alcance" ao executar.

Aqui está o código que usei para aplicar o filtro:

    dbGridSQL_Resultado.Columns.Clear;

   if optControl = 1 then
   begin
      with dbGridSQL_Resultado do
      begin
        DataSource                          := dsFDMemTable;
        Columns.Items[0].Filtering.Editor   := TUniEdit(Self.FindComponent('UniEdit1').Name);
        Columns.Items[0].Filtering.Enabled  := True;
      end;
   end;

 

Erro de imagem:

image.png.ce2f7183a71ff387d825b5b04a4f9a4f.png

Self.FGrid.Columns[i].Filtering.Editor

Link to comment
Share on other sites

1 minute ago, picyka said:

Self.FGrid.Columns[i].Filtering.Editor

But at what point would I put this?

Because I would need to pass in my column 0, a filter, according to what I type in UniEdit.

FGrid.Columns.Items[0].Filtering.Editor := UniEdit;

But that doesn't work, it gives the same error returned in the error image I posted.

Link to comment
Share on other sites

3 minutes ago, Fábio Matte said:

Mas em que ponto eu colocaria isso?

Porque eu precisaria passar na minha coluna 0, um filtro, de acordo com o que eu digito no UniEdit.

FGrid.Columns.Items[0]. Filtragem.Editor := UniEdit;

Mas isso não funciona, dá o mesmo erro retornado na imagem de erro que postei.

 

dbGridSQL_Resultado.Columns[0].Filtering.Editor := UniEdit;

Link to comment
Share on other sites

for var i : Integer := 0 to Self.FGrid.Columns.Count - 1 do
      begin
        if (Self.FGrid.Columns[i].Filtering.Enabled) and (Self.FGrid.Columns[i].Filtering.Editor <> nil) then
        begin
          lUpdate := True;
          if Self.FGrid.Columns[i].Filtering.Editor is TUniEdit then
            TUniEdit(Self.FGrid.Columns[i].Filtering.Editor).Clear
          else
          if Self.FGrid.Columns[i].Filtering.Editor is TUniCheckComboBox then
            TUniCheckComboBox(Self.FGrid.Columns[i].Filtering.Editor).ClearSelection
          else
          if Self.FGrid.Columns[i].Filtering.Editor is TUniDateTimePicker then
            TUniDateTimePicker(Self.FGrid.Columns[i].Filtering.Editor).Text := '';
        end;
      end;

I have something similar.

Link to comment
Share on other sites

On 12/14/2021 at 3:18 PM, picyka said:
for var i : Integer := 0 to Self.FGrid.Columns.Count - 1 do
      begin
        if (Self.FGrid.Columns[i].Filtering.Enabled) and (Self.FGrid.Columns[i].Filtering.Editor <> nil) then
        begin
          lUpdate := True;
          if Self.FGrid.Columns[i].Filtering.Editor is TUniEdit then
            TUniEdit(Self.FGrid.Columns[i].Filtering.Editor).Clear
          else
          if Self.FGrid.Columns[i].Filtering.Editor is TUniCheckComboBox then
            TUniCheckComboBox(Self.FGrid.Columns[i].Filtering.Editor).ClearSelection
          else
          if Self.FGrid.Columns[i].Filtering.Editor is TUniDateTimePicker then
            TUniDateTimePicker(Self.FGrid.Columns[i].Filtering.Editor).Text := '';
        end;
      end;

I have something similar.

image.thumb.png.bd8ce8271c1b75c9e48465ec415c2c6b.png

Thank you friend, it worked perfect, it came out better than I expected.

  • Like 1
Link to comment
Share on other sites

Just now, Fábio Matte said:

image.thumb.png.bd8ce8271c1b75c9e48465ec415c2c6b.png

Thank you friend, it worked perfect, it came out better than I expected.

Code:

              for i := 0 to Self.dbGridSQL_Resultado.Columns.Count - 1 do
                begin
                  if (Self.dbGridSQL_Resultado.Columns[i].Filtering.Enabled) and (Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor <> nil) then
                  begin
                    if Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor is TUniEdit then
                      TUniEdit(Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor).Clear
                    else
                    if Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor is TUniCheckComboBox then
                      TUniCheckComboBox(Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor).ClearSelection
                    else
                    if Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor is TUniDateTimePicker then
                      TUniDateTimePicker(Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor).Text := '';
                  end;

 

  • Like 1
Link to comment
Share on other sites

  • Fábio Matte changed the title to How to set Filtering.Editor in UniDBGrid dynamically? [ Solved ]

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...