Subject Re: TIB_LookupCombo inside TIB_Grid
Author marcoandrecarvalho
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> At 08:18 PM 23/02/2005 +0000, you wrote:
>
>
> >Hi All!
> >
> >Can anyone give me or put a link of some example on how to put a
> >TIB_LookupCombo inside a TIB_Grid? I want to make the following
just
> >like the example that comes with IBO (X:\IBODir\Samples\Company'),
I
> >mean, just put TIB_LookupCombo inside a TIB_Grid.
> >
> >I´ve already tried this with 2 tables:
> >
> > FABRICANTE (Lookup):
> > CD_FABRICANTE SMALLINT PK
> > NM_FABRICANTE VARCHAR(30)
> > /
> > /
> > /
> > <
> > ANTENA (Master):
> > CD_ANTENA SMALLINT PK
> > ID_FABRICANTE SMALLINT FK
> > DESCRIPTION VARCHAR(40)
> >
> >Setup:
> >
> >TIB_Query1 -> TIB_DataSource1 - Master
> >TIB_Query2 -> TIB_DataSource2 - Lookup
> >TIB_Grid -> TIB_DataSource1
> >
> >Assuming all components are clear (Default):
> >
> >IB_Query1.SQL.Text := 'SELECT CD_ANTENA,' +
> > 'ID_FABRICANTE,' +
> > 'DESCRICAO,' +
> > '(' +
> > ' SELECT NM_FABRICANTE' +
> > ' FROM FABRICANTE F' +
> > ' WHERE F.CD_FABRICANTE=A.ID_FABRICANTE ) AS
> >NOMEFABR' +
> > ' FROM ANTENA A;';
> >
> >IBQuery1.KeyLinks.Text := 'CD_ANTENA';
> >IBQuery1.KeyRelation := 'ANTENA';
> >IBQuery1.GeneratorLinks.Text := 'Antena.CD_ANTENA=SEQ_ANTENA_FABR';
> >
> >IBQuery1.OrderingItems.Add('CD_ANTENA=CD_ANTENA;CD_ANTENA DESC');
> >IBQuery1.OrderingItems.Add('DESCRICAO=DESCRICAO;DESCRICAO DESC');
> >IBQuery1.OrderingItems.Add('NOMEFABR=NOMEFABR;NOMEFABR DESC');
> >
> >IBQuery1.OrderingLinks.Add('CD_ANTENA=ITEM=1');
> >IBQuery1.OrderingLinks.Add('DESCRICAO=ITEM=2');
> >IBQuery1.OrderingLinks.Add('NOMEFABR=ITEM=3');
> >
> >IBQuery1.OrderingItemNo := 1;
> >IBQuery1.RequestLive := True;
> >
> >IBQuery2.SQL.Text := 'SELECT * FROM FABRICANTE;';
>
>IBQuery2.KeyLinks.Text := 'FABRICANTE.CD_FABRICANTE=ANTENA.ID_F
A
> >BRICANTE';
>
>IBQuery2.KeyDescLinks.Text := 'FABRICANTE.NM_FABRICANTE=NOMEFABR';
>
>
>
>IBQuery2.MasterLinks.Text := 'Fabricante.CD_FABRICANTE=Antena.ID_F
A
> >BRICANTE'; // ? Needed ?
>
> No, it will break the KeySource-Lookup relationship.
>
>
> >IBQuery2.OrderingItems.Add
('CD_FABRICANTE=CD_FABRICANTE;CD_FABRICANTE
> >DESC');
> >IBQuery2.OrderingItems.Add
('NM_FABRICANTE=NM_FABRICANTE;NM_FABRICANTE
> >DESC');
> >
> >IBQuery2.OrderingLinks.Add('CD_FABRICANTE=ITEM=1');
> >IBQuery2.OrderingLinks.Add('NM_FABRICANTE=ITEM=2');
> >
> >IBQuery2.OrderingItemNo := 1;
> >IBQuery2.RequestLive := True;
> >IBQuery2.KeySource := IB_DataSource2;
> >
> >Then I placed the IBGrid on the form and a TIB_LookupCombo inside
the
> >Grid, just as the manual says (Controls.hlp):
> >
> >"Attention: First click on the grid to select it within the Delphi
> >designer, then click on the TIB_LookupCombo icon in the tool
palette.
> >Finally click on the grid again and the selected TIB_LookupCombo
will
> >show up within the grid. This is the magic trick to make a not
> >standalone lookup rather than one which is automagically used by
the
> >grid!"
> >
> >After all, I didnt succeed. What is wrong or what do i have left?
>
> Remove the master-detail linking. Logically, it is the inverse of
> KeySource-Lookup.
>
> And realise that the embedded lookupcombo will not appear until the
set is
> in edit or insert mode.
>
> Helen

Hi Helen,

Thank you again, Helen!

I forgot to select the DisplayField of the IB_LookupCombo...I did not
give attention in this. Bad thing...

But thank you again!

[]s, Marco André