Control.filter: how to wait untill filter is fully applied?

Hi,
I'm filtering a list/library control with

  let myFilter = '<Eq><FieldRef Name="UserId" /><Value Type="Text">' + myUserId + '</Value></Eq>'
  fd.control('mySPDataTable').filter=myFilter

Based on the filtered value, I want to draw a graph with my function

drawChartFromList("myChart", "Data", 17))

However, without the delay, the graph has the "old" values. Probably because the filter is not (fully) applied before the drawChartFromList started...

If I introduce a short delay, everything works fine-:

  let myFilter = '<Eq><FieldRef Name="UserId" /><Value Type="Text">' + myUserId + '</Value></Eq>'
  fd.control('mySPDataTable').filter=myFilter
  delay(200).then(() => drawChartFromList("myChart", "Data", 17));

so my question is: how can I check if the filter is fully applied?

Kind regards,
Bart Plessers

Dear @bartplessers,
One thing to try here might be to use await:

var dt = fd.control('SPDataTable1');
dt.filter = "<Eq><FieldRef Name='Title'/><Value Type='Text'>Test</Value></Eq>";
await dt.refresh();
alert('Refreshed!');

Hi @Nikita_Kurguzov

Thanx for the tip.
Unfortunately this doesn't work.
Although the .refresh() is async, the .filter isn't.

So what happens (I think) is

  • dt is filtered
  • dt is refreshed BEFORE the filtered data is returned from server

so I'm waiting till the refresh is finished, but not till the filter is finished....

kind regards,
Bart Plessers

Dear @bartplessers,
Hmm, please, try the following:

var dt = fd.control('SPDataTable1');
dt.filter = "<Eq><FieldRef Name='Title'/><Value Type='Text'>Test</Value></Eq>";
await dt.$nextTick();
await dt.refresh()