Display Foreign Key and Related data

Talk about foreign keys

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

alberti47
Senior
Senior
Posts: 28
Joined: Jul 7th, '12, 10:50

Display Foreign Key and Related data

Postby alberti47 » Sep 10th, '12, 06:28

Table1 has KID , foreign key to table2 ID , DESCRIPTION

In Edit mode I want to display on 2 separate and consecutive rows :

.........other fields...........
Foreign Key = KID
Description = DESCRIPTION
........other fields (eventually editables)..........

In edit mode KID IS not edited and no ADD mode is required. This is Just for display.
How define editing columns sequence and foreign key relations ?

Thanks

administrator
Site Admin
Site Admin
Posts: 5992
Joined: Jan 7th, '09, 23:18
Contact:

Re: Display Foreign Key and Related data

Postby administrator » Sep 10th, '12, 07:31

1. Columns are shown in the same order as you define then in your code.
2. Find more info here:
http://www.apphp.com/php-datagrid/index ... reign_keys

alberti47
Senior
Senior
Posts: 28
Joined: Jul 7th, '12, 10:50

Re: Display Foreign Key and Related data

Postby alberti47 » Sep 10th, '12, 08:10

Thanks. I already checked documents You suggested, but nothing related
to the specific question I asked for.
All examples shows how to use foreign keys , also there are information on how to use
concat to display key and data in the SAME ROW.
My question is a bit different : I want to show the data in DIFFERENT row , located just
below the row containing the foreign key.

Regards

administrator
Site Admin
Site Admin
Posts: 5992
Joined: Jan 7th, '09, 23:18
Contact:

Re: Display Foreign Key and Related data

Postby administrator » Sep 11th, '12, 09:05

Do you mean another data that doesn't related to edited table?

You may retrieve it and use in "post_addition"=>"<br>...you HTML code/Description/Text here.." in a foreign field

alberti47
Senior
Senior
Posts: 28
Joined: Jul 7th, '12, 10:50

Re: Display Foreign Key and Related data

Postby alberti47 » Sep 12th, '12, 10:31

Not exactly what I need.
At least the is a way to get (for foreign_keys type 'label' only) an output like :

31 - Description of 31

where 31 is the value of the field key , and 'Desription' is the value of the foreign
got from the foreign table.
For the foreign keys type label what is outputted is a
pre_addition (contains only foreign value) followed by post_addition (whater You want)

What I simple need is that pre_addition contains the value of the key , followed by value
of the foreign.
Regards

administrator
Site Admin
Site Admin
Posts: 5992
Joined: Jan 7th, '09, 23:18
Contact:

Re: Display Foreign Key and Related data

Postby administrator » Sep 13th, '12, 08:45

Try to defile a filed output in a following way:

'field_name'=>'CONCAT(field1,' ',field2) as field3'

or use any other construction to get a needed text value.
Does it help now?

alberti47
Senior
Senior
Posts: 28
Joined: Jul 7th, '12, 10:50

Re: Display Foreign Key and Related data

Postby alberti47 » Sep 13th, '12, 09:37

No. Thanks anyway.


Return to “Field type: "foreign key"”