I am getting an exception that was making no sense.
I traced it. Its ion this code, unit JSONDataset
function TBaseJSONDataSet.GetFieldData(Field: TField; Buffer: TDatarecord): JSValue;
var
R : JSValue;
begin
if State in [dsCalcFields,dsInternalCalc] then
R:=CalcBuffer.data
else if (State=dsFilter) then
R:=FFilterRow
else if (FEditIdx=Buffer.Bookmark) then
begin
if State=dsOldValue then
R:=Buffer.data
else
R:=FEditRow;
end
else
begin
if State=dsOldValue then
Exit(Null)
else
R:=Buffer.data;
end;
Result:=FFieldMapper.GetJSONDataForField(Field,R); <-------------------
if isUndefined(Result) then
Result:=Null;
end;
FFieldmapper is null. What does this mean? What havent I done ?
I am using Load after setting a filter. I was setting up 5 of these datasets and then a small timer delay. This worked in Insert mode of the main table. But was failing in View or Edit mode.
On a hunch, I extended my timer and it works.
Is there anything else I can use apart from LoadAsync ? I assume that this halts the "thread" until the dataset is loaded, which is not ideal.
Does this freeze the execution of the code though?
On reading the docs, it would seem that if I use Load, it returns right away. But calls Open when its loaded the data. So, could I use AfterOpen event ???