edbuescher Posted July 27, 2022 Share Posted July 27, 2022 I have a filtered TUniDBGrid with multiple columns and with the option dgFilterClearButton set. How do I simulate either 1) Clicking the Filter Clear Button or 2) Clicking the 'X' on the filtered Columns to disable those column filters I can clear the underlying filter on the dataset, but that doesn't clear the various Column filtering criteria Thanks Quote Link to comment Share on other sites More sharing options...
picyka Posted July 27, 2022 Share Posted July 27, 2022 54 minutos atrás, Edbuescher disse: Tenho um TUniDBGrid filtrado com várias colunas e com a opção dgFilterClearButton definido. Como simular 1) Clicar no botão de limpar filtro ou 2) Clicar no 'X' nas colunas filtradas para desativar esses filtros de coluna Eu posso limpar o filtro subjacente no conjunto de dados, mas isso não limpa os vários critérios de filtragem de coluna Obrigado 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; Quote Link to comment Share on other sites More sharing options...
edbuescher Posted July 28, 2022 Author Share Posted July 28, 2022 Obrigado, Thank you for your sample code, however it doesn't actually clear the filters. Example: if I have a grid with 20 rows and one of the columns displays Dates, then I use a UniDateTimePicker column editor to filter the column to a specific date, such as 8/10/2022, the grid will respond and only show rows with that date. Then if I run your code and set the UniDBGrid.Filter:='', I will be back to showing all 20 rows. At this point if I use the drop down menu for the UniDateTimePicker and choose 8/10/2022 again, nothing happens, as the Grid still thinks that's the selected date being used. If I select a different date, then the filtering works on the new date. I've tried this on the other types of column editors (UniComboBox, etc) with the same effect. If there is a way to click the Grid's "FilterClearButton" on the left side of the columns, that would solve the problem. I'm open to suggestions. Thanks again, Eric Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 28, 2022 Share Posted July 28, 2022 Hello, You can do it on the server side. Quote Link to comment Share on other sites More sharing options...
edbuescher Posted July 28, 2022 Author Share Posted July 28, 2022 Sherzod, I am doing this on the server side via Delphi code. I must be missing something. In Delphi, how do I click the Grid's FilterClearButton on the left side of the columns, or how do I click on the 'x' in a particular Column heading to clear the filtering for that column? Eric Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 29, 2022 Share Posted July 29, 2022 10 hours ago, edbuescher said: I am doing this on the server side via Delphi code. Hello, Have you tried this method? UniDBGrid1.ClearFilters; Quote Link to comment Share on other sites More sharing options...
picyka Posted July 29, 2022 Share Posted July 29, 2022 5 horas atrás, Sherzod disse: Olá Você já tentou esse método? UniDBGrid1.ClearFilters; Great, I didn't know this one. Quote Link to comment Share on other sites More sharing options...
edbuescher Posted July 29, 2022 Author Share Posted July 29, 2022 Don't know how I missed that, but it still doesn't clear the underlying filter. After executing the Grid.ClearFilters, the grid does display all the rows as though the filters were all cleared, but if you select the last thing you filtered on, the Grid doesn't respond because it still "knows" the last thing you filtered on, even After the ClearFilters command. Do I need to write a sample program to demonstrate? Thanks again, Eric Quote Link to comment Share on other sites More sharing options...
picyka Posted July 29, 2022 Share Posted July 29, 2022 2 hours ago, edbuescher said: Não sei como eu perdi isso, mas ainda não limpa o filtro subjacente. Depois de executar o Grid.ClearFilters, a grade exibe todas as linhas como se os filtros estivessem todos limpos, mas se você selecionar a última coisa que filtrou, a grade não responderá porque ainda "sabe" a última coisa que você filtrou ligado, mesmo após o comando ClearFilters. Preciso escrever um programa de exemplo para demonstrar? Obrigado mais uma vez, Érico here it helped me, after cleaning it, I send it to update the query Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 30, 2022 Share Posted July 30, 2022 9 hours ago, edbuescher said: Do I need to write a sample program to demonstrate? Okay, please make a simple testcase if possible. We will check. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 30, 2022 Share Posted July 30, 2022 12 hours ago, edbuescher said: After executing the Grid.ClearFilters... Also try this code: procedure TMainForm.UniButton2Click(Sender: TObject); begin with UniDBGrid1 do if (dgFilterClearButton in Options) then JSInterface.JSCallGlobal(Self.Name + '.' + Name + 'ClearButton.click', []) end; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.