I have a dhtmlx-grid created from multiple tables. And I am able to edit the main table but not the joined ones.
The dhtmlx guides are rather vague on creating a grid from multiple tables and making it fully editable.
I followed the steps here:
http://docs.dhtmlx.com/connector__php__complex_queries.html#complexqueries
http://docs.dhtmlx.com/connector__php__basis.html#loadingfromdatabase
and tried to create a connection, but failed.
I'm using their php-connector and the code that I tried is as follows:
$jpnx_regs = new GridConnector($conn,'MySQL'); // connector initialization
$jpnx_regs->sql->attach("Update","
UPDATE wp_japanextion_attendance_data
LEFT JOIN wp_buyer_employee
ON wp_buyer_employee.ID = wp_japanextion_attendance_data.ID_employee
LEFT JOIN wp_buyer_company
ON wp_buyer_company.ID = wp_buyer_employee.ID_company
SET
reg_user='{reg_user}',
reservation_date='{reservation_date}',
reservation_hour='{reservation_hour}',
copy_company_name='{copy_company_name}',
copy_company_TEL='{copy_company_TEL}',
copy_name='{copy_name}',
copy_mobile_TEL='{copy_mobile_TEL}',
copy_email='{copy_email}',
rec_creation_date='{rec_creation_date}',
iploc='{iploc}',
trackvia_inserted='{trackvia_inserted}'
WHERE id='{id}'
");
$jpnx_regs->render_complex_sql("
SELECT
*, wp_japanextion_attendance_data.ID AS jpnx_ID,
wp_buyer_employee.ID AS employee_ID,
wp_buyer_company.ID AS buyer_ID,
FROM
wp_japanextion_attendance_data
LEFT JOIN wp_buyer_employee
ON wp_buyer_employee.ID = wp_japanextion_attendance_data.ID_employee
LEFT JOIN wp_buyer_company
ON wp_buyer_company.ID = wp_buyer_employee.ID_company
WHERE
reservation_date LIKE '%November%' OR
reservation_date LIKE '%December%' OR
reservation_date LIKE '%January%'
", "jpnx_ID","
reg_user,reservation_date,reservation_hour,company_name,company_TEL,name,mobile_TEL,email,rec_creation_date,iploc,trackvia_inserted,ID
");
↑ Just as their guide says. I first initialize the grid like this:
$jpnx_regs = new GridConnector($conn,'MySQL');
Then I attach the update action:
$jpnx_regs->sql->attach("Update"," ... sql code here
Then I render the grid with the render_complex_sql.
$jpnx_regs->render_complex_sql("
BTW, just in case, here down below is my working code for my grid from multiple tables but I can only update the main table:
$jpnx_regs = new GridConnector($conn,'MySQL');
if ($jpnx_regs->is_select_mode())
$jpnx_regs->render_sql("
SELECT
*, wp_japanextion_attendance_data.ID AS jpnx_ID,
wp_buyer_employee.ID AS employee_ID,
wp_buyer_company.ID AS buyer_ID,
FROM
wp_japanextion_attendance_data
LEFT JOIN wp_buyer_employee
ON wp_buyer_employee.ID = wp_japanextion_attendance_data.ID_employee
LEFT JOIN wp_buyer_company
ON wp_buyer_company.ID = wp_buyer_employee.ID_company
", "jpnx_ID","reg_user,reservation_date,reservation_hour,company_name,company_TEL,name,mobile_TEL,email,rec_creation_date,iploc,trackvia_inserted,ID
");
else //code for other operations - i.e. update/insert/delete
$jpnx_regs->render_table("wp_japanextion_attendance_data","id","
reg_user,reservation_date,reservation_hour,copy_company_name,copy_company_TEL,copy_name,copy_mobile_TEL,copy_email,rec_creation_date,iploc,trackvia_inserted");