Page 1 of 1

Search bar initialization issue on form load

PostPosted: 01 Oct 2019 16:41
by bob9999
Hi there. I ran into an interesting combination of events so I wanted to share here to hopefully save someone else some time. The search bar or toolbar search is a great way for a user to have multiple filters at a time for grid contents. The issue is that when I had the dataset in the user session so I can share the dataset between forms, the state of the search is remembered in the dataset somehow. So when the form loads again, the search bar is cleared as it is supposed to be but under the hood in the dataset the last search state is still remembered.

So if you are using the search bar feature, make sure your dataset for the grid is on the form as well. This way the dataset is recreated from scratch when the form renders and then the search bar state is also cleared.

I just ran into the situation again for another project and remembered this time I put in to figure this out so I had to remove the search bar since I had to have the dataset in that solution in the user session.

Cheers!

Re: Search bar initialization issue on form load

PostPosted: 08 Oct 2019 19:40
by ScottWGast
Thanks! It's little tidbits like this that help so much.

Scott

Re: Search bar initialization issue on form load

PostPosted: 26 Apr 2021 14:56
by omonien
For those who are interested:
A Grid Search is implemented by applying a filter to the underlying TDataset. IOW, the Dataset will have Filtered := true; which is then kept active.

If you reuse a dataset, then first do a Dataset.Filtered:=false. I do this in Form.OnRender - where I work recursively through all DatasetProviders.