TXDataWebDataSet QueryString and/or Filter

Good afternoon,
i have a little web application that have a connection, 2 webedit, webbutton and 2 ttmsfncgrid with xdatawebdataset (with their entity set).

Once set the edit and pressed the button i perfom the call on the first webdataset in this way

procedure TForm2.WebButton2Click(Sender: TObject);
Var S : String;
begin;
S:='$filter=startswith(Descrizione,' + QuotedStr(UpperCase(WebEdit1.Text)) + ')';
XDS1.Close;
XDS1.QueryString:=S;
XDS1.Load;
end;

In the AfterOpen event i have all the records according to the request and, with the second webdataset, i perform a second query to his entity (table).

The code is

procedure TForm2.XDS1AfterOpen(DataSet: TDataSet);
var S : string;
begin
if XDS1.RecordCount>0 then
begin
FNCG1.DeleteRows(1,FNCG1.RowCount - 1); // Clear the grid
XDS1.First;
S:='$filter=(EAN eq ';
while not XDS1.Eof do
begin
S:=S + QuotedStr(Trim(XDS1.FieldByName('EAN').AsString)) + ' and QTA gt 0)';
XDS1.Next;
if not XDS1.Eof then
begin
S:= S + 'or (EAN eq ';
end;
end;
XDS1.First;
end
else
begin
FNCG1.DeleteRows(1,FNCG1.RowCount - 1);
end;

XDS2.Close;
XDS2.QueryString:=S;
XDS2.Load;

end;

This code works if the selected items are <30.

If the items are >30 the string is very very long and i got an error.
There's a way to call a afterload procedure (on second xdatawebdataset) more times?
For example i created an array with one or more query string, but in the afterload procedure i work alway with the first one.

Excuse me if i did not clear enough.

Thank's for attention

Regards

Daniele

In this case I think it's better that you perform the requests manually instead of using the dataset. For example, you could perform different request for each record (or a batch of records) using TXDataWebClient, then join the results and once you get all the results, "put" it in the second dataset using

XDS2.SetJsonData(MyResults);