TSeba Posted July 17, 2017 Posted July 17, 2017 Hi: I need to delete from the OnClick event of a TUniButton filters the columns of a UniDbGrid. I'm using Tokyo 10.2. The grid with data I can restore it without filters but I can't delete the texts entered in the filters of the columns. Thank you in advance for your help. Quote
Sherzod Posted July 18, 2017 Posted July 18, 2017 Hi, Can you clarify your question again please ? Best regards, Quote
TSeba Posted July 19, 2017 Author Posted July 19, 2017 Hi, I hope I can clarify what I need I'm using a UniFormGrilla. When loading the grid that is associated with an advantage table, filters are automatically generated for each column by executing the following procedure: Var I: Integer; VTUniEdtTemp: TUniEdit; Begin For I: = 0 to UniDbGdDatos.Columns.Count - 1 of Begin If (UniDbGdDatos.Columns .FieldName <> 'Company') then Begin VTUniEdtTemp: = TUniEdit.Create (Self); VTUniEdtTemp.Parent: = UniHiPnFilters; VTUniEdtTemp.EmptyText: = UniDbGdDatos.Columns .FieldName + '...'; VTUniEdtTemp.Name: = 'UniEdt' + UniDbGdDatos.Columns .FieldName; UniDbGdDatos.Columns .Filtering.Editor: = vTUniEdtTemp; UniDbGdDatos.Columns .Filtering.Enabled: = true; End Else Begin UniDbGdDatos.Columns .Visible: = false; End; End; End; In summary, I need to be able to simulate at runtime the JS function that is executed by pressing the button dgFilterCrearButton but from another Button?. Regards. Quote
Sherzod Posted July 19, 2017 Posted July 19, 2017 Hi, Like this ?!: procedure TMainForm.UniButton1Click(Sender: TObject); begin UniDBGrid1ClearFilters(UniDBGrid1); end; Best regards, Quote
TSeba Posted July 20, 2017 Author Posted July 20, 2017 Hi, It is correct what I say but that does not delete the filters that is what I am missing. I tested by adding the following inside the Clean Button: UniSession.AddJS (UniDbGdDatos.JSName + '.store.clear ();'); But at runtime I get the error "XXXX.store.clear is not a function". That JS code is what I'm missing seems to me. Regards. 1 Quote
Sherzod Posted July 20, 2017 Posted July 20, 2017 Hi, Have you seen this demo ?!: \FMSoft\Framework\uniGUI\Demos\Desktop\GridFiltering-2 Quote
TSeba Posted July 20, 2017 Author Posted July 20, 2017 Yes, I saw that example and to see if I can be clearer I copy the procedure to clean the filters: Procedure TMainForm.UniDBGrid1ClearFilters (Sender: TObject); Var I: Integer; Begin If UniMainModule.ADOQuery1.Active then Begin For I: = 0 to UniMainModule.ADOQuery1.Parameters.Count-1 UniMainModule.ADOQuery1.Parameters .Value: = '%%'; UniMainModule.ADOQuery1.Requery; End; End; Suppose I comment on the whole procedure: Procedure TMainForm.UniDBGrid1ClearFilters (Sender: TObject); Var I: Integer; Begin {If UniMainModule.ADOQuery1.Active then Begin For I: = 0 to UniMainModule.ADOQuery1.Parameters.Count-1 UniMainModule.ADOQuery1.Parameters .Value: = '%%'; UniMainModule.ADOQuery1.Requery; End; } End; When you press the delete button on the left, and as the procedure is commented, the grid information is obviously not restored, but the texts entered in the columns are deleted. This behavior, the one to delete the texts of the columns, is what I have to replicate from a TButton. I think it has nothing to do but I am not using Querys but I use AdsTables. Regards. Quote
Gabriel Posted July 28, 2017 Posted July 28, 2017 Hi. I was able to clean the filter from a TButton by simple iterate over them and set the text to ''. But a strange things happen. Lets say I filter the first column with the value 1. Works like a charm. Now, I use the UniButton to clear all the filter and refresh the grid. Also Works like a charm. The issue begin when I want to set the filter to the first column again, if I put a value different from the original value I entered (1 in this case) it works, but if I use 1 again, it doesn't work until I type another value. Is like the filter keep remembering the original value and the event doesn't get executed. Quote
Sherzod Posted July 28, 2017 Posted July 28, 2017 Hi Gabriel, Please, can you make a testcase for this ?! Best regards, Quote
Gabriel Posted July 31, 2017 Posted July 31, 2017 Hi, I've change the GridsFilter demo. You can add a button, and put the next code on the OnClick event: procedure TUniGridsFilter.UniButton2Click(Sender: TObject); begin UniDBGrid1ClearFilters(self); UniEdit1.Text := ''; end; of course, this will only work with the first filter. After you run the project, filter the first column, let's say with the letter "Z". The filter works. Click on the new button, and the filter will disappear. If you put "Z" again on the first filter it will not work. By the way, another related question. ¿It is posible to call the dgFilterClearButton event with Javascript? Regards Quote
Colas_96 Posted October 20, 2022 Posted October 20, 2022 I know it's been a long time since the post was created, but it could be helpful for someone like me who gets redirected to this page looking for the same problem 🙂 Solution: UniDBGrid1.ClearFilters; Quote
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.