TWebDBEditDropDownTableControl row selection

Hi,
I'm trying to extend the functionality of TWebDBEditDropDownTableControl so that it behaves more like a lookup-table component.

I can successfully locate the record in the lookup dataset, but I can't figure out how to select the corresponding row in the dropdown table.

Here’s the code I’ve tried (without success):

procedure TForm1.WebDBEditDropDownTableControl1DropDown(Sender: TObject);
var
  tmpEditor: TWebDBEditDropDownTableControl;
  tmpDataset: TDataSet;
  tmpLookupDataset: TDataSet;
begin
  tmpEditor := TWebDBEditDropDownTableControl(Sender);

  tmpDataset := tmpEditor.DataSource.DataSet;
  tmpLookupDataset := tmpEditor.TableSource.DataSet;

  if tmpLookupDataset.Locate(
       tmpLookupDataset.Fields[tmpEditor.EditColumn].FieldName,
       tmpDataset.FieldByName(tmpEditor.DataField).AsString,
       [loCaseInsensitive]
     ) then
    tmpEditor.Table.SelectCell(tmpEditor.EditColumn, tmpLookupDataset.RecNo);
end;

Is there another way to achieve row selection in the dropdown table?

After further testing, it appears that the grid is only occasionally able to correctly select the active record, which suggests the issue may be related to timing. Unfortunately, there don’t seem to be any events or procedures that can be easily overridden to handle these timing problems, and using a timer would not be a safe or reliable solution.

In addition to this, many of the settings in the Object Inspector under TableOptions (such as Paging, Footer, and Header) don’t seem to have any noticeable effect on the grid’s functionality. I’m not sure whether these options are intended to work as-is or if I might be misconfiguring them. However, having a fully functional Paging feature would significantly improve the usefulness and practicality of this component.

The dropdown table was not designed to show the active row in sync with the TableSource dataset active row, but with the DataSource selected value.
You can access the table though via WebDBEditDropDownTableControl.Table and use the SelectCell() method for example.
We're investigating the use of TableOptions at design-time and will try to improve this.
At runtime, you can also access these options via WebDBEditDropDownTableControl.Table.Options

I'm also reporting a bug.

Steps to reproduce:

  1. Bind control to a div using ElementID → works fine.
  2. Unbind control.
  3. Re-bind control to the same or another div using ElementID.

Expected: Control reattaches without duplication.
Actual: A new copy of the component is created each time after the first assignment.

Put TWebDBEditDropDownTableControl in a WebHTMLDiv and bind/unbind this to a regular DIV HTML element.

1 Like