TXDataWebDataset filter function is very slow in Webcore project

Hi,

I am using TXDatawebdataset component to store data got from API developed using TMS XData. I am using a TWebDBGrid to show the data collected.

I have a edit box and on text change I am filtering the XdatWebdateset locally so that it will not required to call the API again and again.

The filter works but it seems very slow. The filter is basic function and should be much faster.

I have attached the attachments showing the result. In attachment, I have typed 'indus' and it filtered the xdatasebdataset but it is very slow as you can see the start and end times that I logged.

So why the filter is slow and how to speed up the process?

  try
    waitMsg1.Show;

    searchText := edtSearch.Text;

    Condition :=' CUSTNO like ''%'+searchtext+'%'' '+
            ' or SHORTNAME like ''%'+searchText+'%'' '+
            ' or CUSTNAME like ''%'+searchText+'%'' '+
            ' or POSTCODE like ''%'+searchText+'%'' '+
            ' or POSTTOWN like ''%'+searchText+'%'' ';

    Console.log(Condition);
    Console.log('Filter Start: '+FormatDateTime('dd-mm-yyyy hh:nn:ss:zzz', now));

    webdsCustomer.Filter := Condition;
    webdsCustomer.Filtered := True;

    Console.log('Filter End: '+FormatDateTime('dd-mm-yyyy hh:nn:ss:zzz', now));

  finally
    waitMsg1.Hide;
  end;

@wlandgraf

Hi!
I think it's not that the filter is too slow.
When you make this kind of automatic filtering while the user types a search text, you must implement some timer logic in order not to filter immediately on every new typed character.
For example, if nothing is typed in 1 second, then filter.
It took you 12 seconds to filter 'indus', because it filtered for i,in,ind,indu and indus. You should wait for the user to stop typing for a while.

For example, place and set a timer to disable itself and call your filter routine on every 1000 ms (I've been using 500ms in VCL for years. It works great).
In your edit field OnChange event, disable and enable the timer - this will reset the 1 sec counting.
This way you'll prevent filtering while the user is still typing what he wants to search.

How many rows do you have in the dataset?
You need to take in account that TWebDBGrid will always load and display ALL rows. So, internally, a HTML table is created with rows x columns cells. Filtering means unloading & loading potentially a lot of cells.
TTMSFNCDataGrid works with buffered display, i.e. will only work with the visible rows and will therefore be more performant in scenarios with many rows and filtering these.