0

I am developing a mobile device for Android and iOS. I need to populate data to my TListView with search functionality. I am using a local database for this development with SQLite3 having 100,000 records in one table alone.

Now, everything was so smooth, and this approach really serves the purpose I want. EXCEPT, only when I ran it in my Android mobile device, the loading of data to listview takes so much time (4.3 seconds) and this is not good.

Here are my attempts made so far but no avail:

  • I tried to limit my TFDQuery to top 20, but it is not implementing to the search function of listview. I am still trying a way where I could trigger the query right after or during the typing of an item in the search box of listview.

  • I used the property of query RecMax = 20. But then again, it failed! Perhaps, the search function works after the data is loaded to the listview.

Here are some of the approach I haven't tried yet:

  • Manually code the loading of data to my listview. I don't want to do this because it looks to me like re-inventing the wheel. Though, this could be my last option, in case.

I believed somewhere somebody has got an answer with this. This is a very basic feature of the mobile device that you can find every day like Alibaba, Amazon, and eBay.

I want the search function of my listview to load only the top 20 searches from my database. Is there any simpler way to do this?

Juke
  • 135
  • 2
  • 9
  • You need to explain in your q what you mean by "it is not implementing ..." and "it failed". Statements that something is "not working" are not useful descriptions of a problem, any more that taking your car to a garage and only telling them "It does not work." – MartynA May 03 '20 at 07:27
  • @MartynA what I am trying to say of "it is not implementing.." and "it failed" is — I want the search of listview to load prior to tfdquery is fired. It appears to me that the search functionality of the listview can only filter the items already loaded by fdquery. What I am trying to achieve or hope for at least is that... Is it possible that I could be able to trigger the fdquery right after I typed (or during typing with delay, perhaps) the keywords in the search area and the fdquery kicks-in. In this way, I could avoid the heavy load of data that is taking up 4.3 seconds for 100k records. – Juke May 03 '20 at 21:35
  • Well first make sure the ‘active’ property of your fdquery is set to false in the designer (this allows you to control when it actually executes the first time. Them make sure the fdquery loads only 20 record from the 100.000 without any filter set. They, when searching, adjust the filter of the fdquery, when you type in your search term. – R. Hoek May 03 '20 at 21:52
  • @R.Hoek Actually, that can be done if I don't use the search.visible of the TListView. Say, I will create a TEdit separately as my search box. But, I would like to avail of the search feature of TListView. Do you have any idea how can I trigger fdquery from the listview search function? – Juke May 04 '20 at 05:13
  • It's best to get your FD dataset(s) working as you wish entirely independently of your app's gui. Only once you have achieved that, integrate your dataset's behaviour with your app's gui. Otherwise you risk ending up chasing your own tail. – MartynA May 04 '20 at 21:09
  • @MartynA Yes exactly! That's what I was trying to do. Having a separate search box outside listview is my other option. Right now, I am struggling with the implementation using parameters at tfdquery and fire at tedit.onchangetracking. But that is not my question here. I would like to know if I can trigger the opening of dataset from listview.search itself via query.active := true perhaps? If yes, a clue would be much appreciated. – Juke May 04 '20 at 23:53

0 Answers0