[Lazarus] MaskEdit: question on how it should behave

Bart bartjunk64 at gmail.com
Sat Dec 27 01:07:34 CET 2008


Hi again, my TSQLite3Dataset components:

DatasetSales with the fields: Code, Item, Amount, Price, Vendor
DatasetItems with the fields: Code, Description

I do not want that the lookup field to be editable.

My new code:

procedure TForm1.FormCreate(Sender: TObject);
var
  TempField: TStringField;
begin
  DatasetSales.Active := true;
  TempField := TStringField.Create(DatasetSales);
  with TempField do
    begin
      FieldName := 'New field';
      Lookup := True;
      FieldKind := fkLookup;
      KeyFields := 'Item';
      LookupDataSet := DatasetItems;
      LookupKeyFields := 'Code';
      LookupResultField := 'Description';
      DatasetSales := Self.DatasetSales;
    end;
end;

but nothing happen. Why?

2008/12/25 Alexander Klenin <klenin at gmail.com>:
>>> I do it:
>>> procedure TForm1.FormCreate(Sender: TObject);
>>> begin
>>>   with DatasetSales do
>>>   begin
>>>   Open;
>>>   DatasetItems.Open;
>>>   FieldByName('Item').FieldKind := fkLookup;
>>>   FieldByName('Item').LookupDataSet := DatasetItems;
>>>   FieldByName('Item').LookupKeyFields := 'Code; Description';
>>>   FieldByName('Item').LookupResultField := 'Code';
>>>   end;
>>> end;
>
> 1) You forgot to set KeyFields
>  (or, rather, FieldName -- it should be different form KeyFields or
> DBGrid might be confused)
> 2) You probably mixed up LookupKeyFields with LookupResultField
> 3) If you want the lookup field to be editable, you will need
> to use Lazarus version later then http://bugs.freepascal.org/view.php?id=12347
> and to set LookupCache := true
> 4) Even after this, there is some problems in SQLdb which I did not
> yet found time
> to diagnose and fix properly. They cause AVs while scrolling DBGrid.
>
> On Thu, Dec 25, 2008 at 12:08, Luiz Americo Pereira Camara
> <luizmed at oi.com.br> wrote:
>> It's not implemented in TSqlite3Dataset. In fact i don't know in which
>> layer (TDataset / TDataset descendant / TDbGrid) should be implemented.
>>
>> It's up to TDataset descendants implement this?
>>
>> Does some descendant already implemented ?
>
> It seems to be implemented in SQLdb (TBufDataset).
> So, in addition to the above, original poster should indeed drop sqlitedataset.
> Perhaps TSQLite3Connection can be ised instead?
>
> --
> Alexander S. Klenin
> _______________________________________________
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>



More information about the Lazarus mailing list