In the attached zip, I added a TWebIndexedClientDataSet
and the below code to the TMS dataset samples project. The added code does work to enable continued viewing of the downloaded data after the connection is broken. I anticipated that it would also be possible for the data to persist in subsequent runs via the IndexedDB, but the browser dev panel says there is no IDB created. What am I doing wrong?
A related question: Couldn't the TWebClientDataSet
be written to TWebLocalStorage
as JSON in a string to be fetched back on a subsequent run of the app? How to do that?
***
WebButton1.Tag := 1;
WebButton1.Caption := 'Disconnect';
// Make a clone of the downloaded dataset to view offline
// The following line succeeds in transferring the DS to the IDBCDS, but only in memory
WebIndexedDbClientDataset1 := TWebIndexedDbClientDataset(WebClientDataSet1.GetClonedDataSet(False));
// The following seems to have no effect in writing to the actual IDB according to the browser console
WebIndexedDbClientDataset1.First;
while not WebIndexedDbClientDataset1.Eof do
begin
WebIndexedDbClientDataset1.Edit;
TAwait.ExecP<Boolean>(WebIndexedDbClientDataset1.PostAsync);
WebIndexedDbClientDataset1.Next;
end;
WebDataSource1.DataSet := WebIndexedDbClientDataset1; // View IDBCDS in browser app after closing connection
***
TWCDS_Demo.zip (6.7 KB)