linktoedit on two tables

Talk about link fields or link implementations

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

tom_morello
Newbie
Newbie
Posts: 2
Joined: Aug 11th, '09, 14:16

linktoedit on two tables

Postby tom_morello » Aug 11th, '09, 15:06

Hello,

I hope I have a simple question.
When I create a grid as a join over two tables, for example customer and product

Customer
----------
cus_id
cus_name

Product
----------
pro_id
pro_name
pro_fk_cus => fk to customer table

With the select statement:
Select * from customer left Join On(Customer.cus_id=Product.pro_fk_cus);

I need a grid with two linktoedit colums: cus_name, pro_name. When I click on cus_name I like to see only the customer in edit mode and when I click on the pro_name colum I like to see the product in edit mode.

With
## +---------------------------------------------------------------------------+
## | 7. Add/Edit/Details Mode settings: |
## +---------------------------------------------------------------------------+
## *** set settings for edit/details mode
$table_name = "customer";
$primary_key = "cus_id";
$condition = "";
$dgrid->setTableEdit($table_name, $primary_key, $condition);
$dgrid->setAutoColumnsInEditMode(true);
$dgrid->autoColumns=false;

$table_name = "product";
$primary_key = "pro_id";
$condition = "";
$dgrid->setTableEdit($table_name, $primary_key, $condition);
$dgrid->setAutoColumnsInEditMode(true);
$dgrid->autoColumns=false;

I only see the product in edit mode, because I`m overwriting the first setTableEdit function.
Question: Is it possible to have two links to edit on two different tables in one datagird when the datagirds origin is a Join?

Thank you very much for you help, i tried hard to find a solution. :roll:

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

Re: linktoedit on two tables

Postby administrator » Aug 15th, '09, 18:56

The best way is to create a customized Edit links (read here: viewtopic.php?f=33&t=369),
each of them leads to separate page or passes a parameter, that can be used in "if", like this:

Code: Select all

if(first-link_edit){

  ## *** set settings for edit/details mode
  $table_name = "customer";
  $primary_key = "cus_id";
  $condition = "";
   ........
}else if(first-link_edit){

  ## *** set settings for edit/details mode
  $table_name = "product";
  $primary_key = "pro_id";
  $condition = "";
  ......
}

tom_morello
Newbie
Newbie
Posts: 2
Joined: Aug 11th, '09, 14:16

Re: linktoedit on two tables

Postby tom_morello » Aug 28th, '09, 06:24

thank you. :)


Return to “Field type: "link"”