Issue with the GridPlugin code

I have copied this from the examples and on the whole it works very well. The issue I have is that when there are no results for the search I get the following exception:

Uncaught TypeError: Cannot read properties of undefined (reading 'Id')
    at Object.GetPropValue (XData.Web.JsonDataset.pas:155)
    at Object.GetJSONDataForField (XData.Web.JsonDataset.pas:116)
    at Object.GetJSONDataForField$1 (jsondataset.pas:997)
    at Object.GetFieldData$1 (jsondataset.pas:1693)
    at Object.GetFieldData (db.pas:3892)
    at Object.GetData (db.pas:5577)
    at Object.GetValue (db.pas:6252)
    at Object.GetAsString (db.pas:6221)
    at Object.$impl.FieldToCellData (WEBLib.DBCtrls.pas:766)
    at Object.LoadRow (WEBLib.DBCtrls.pas:2931)

Any ideas where to start looking to head this off?

Can you please give us more context information? What did you do exactly, code used, preferable a sample reproducing the issue?

How about I give you a login to our dev site?

I don't think that it would help in inspecting your source code, debugging...?

It is in debug mode so you can step through it in developer tools. But I'll see if I can do a sample version.

1 Like

@wlandgraf I have tracked this down further. The issue is not being raised in the plugin but in the TWebDBTableControl.

When the Plugin calls EnableControls various events fire on TWebDBTableControl. The key one is procedure TDBTableControl.RecordChange(Sender: TObject);

    r := FDataLink.DataSource.DataSet.RecNo - 1; //set r = -1

    if RowHeader then
      inc(r);  //sets r = 0

so the call is then LoadRow(0)

the problem is then raised in

if Assigned(lField) then
        cd := FieldToCellData(ce, lField, Columns[c].DataType, false);

I think the actual exception was in procedure

TXDataWebClient.DoLoad(Response: TXDataClientResponse;
  SuccessProc: TXDataClientLoadProc; AsyncMode: Boolean);

but I was so far down the step through rabbit hole by then that I''m not completely sure.

Here's the flow:

XData.Web.JsonDataset.pas:155

Uncaught TypeError: Cannot read properties of undefined (reading 'Id')
at Object.GetPropValue (XData.Web.JsonDataset.pas:155)
at Object.GetJSONDataForField (XData.Web.JsonDataset.pas:116)
at Object.GetJSONDataForField$1 (jsondataset.pas:997)
at Object.GetFieldData$1 (jsondataset.pas:1693)
at Object.GetFieldData (db.pas:3892)
at Object.GetData (db.pas:5577)
at Object.GetValue (db.pas:6252)
at Object.GetAsString (db.pas:6221)
at Object.$impl.FieldToCellData (WEBLib.DBCtrls.pas:766)
at Object.LoadRow (WEBLib.DBCtrls.pas:2931)

We really need a way to reproduce and debug it on our side.

I'll see what I can do.

A little bit more info - if the first search you do returns 0 records then it is fine and continues to be fine if subsequent searches return 0 records. It is only if you do a 0 result search AFTER you do a search that returns a a result.

1 Like

there is an issue with the music demo, which is not quite as extreme, but probably has the same source. If you search for something that isn't there then the last result remains visible, while the pagination displays 'showing record 0 of 0'. In this case the tablecontrol should be empty - which I would think is the way it would be designed.

@wlandgraf I have a demo app and just sent an email to support with details for download etc

1 Like

We could trace & solve this issue.
The next update will address this.

1 Like

Is there a patch I could apply now?