Editor not updating joined fields
Editor not updating joined fields
I have one table (tbl_BR_inspections) from which I am needing to view ALL the rows but edit NONE, and another table (tbl_lifecycle) that I am joining that contains extra info related to many, but not all, of the rows of the first table. I need to show the info from tbl_lifecycle and EDIT many of the fields from it as well. I can INSERT new rows in tbl_lifecycle via inline editing, but I cannot UPDATE existing rows. After reviewing the mysql logs, the UPDATE query is not getting sent to the server.
I thought I had found a solution in the below post, but adding the ID for the joined table (tbl_lifecycle.UIID) didn't fix it and I still feel this is somehow at the heart of my problem. https://datatables.net/forums/discussion/26580/edit-feature-is-not-editing-the-join-fields
Please take a look at the below code for my current setup. Any help is GREATLY appreciated!
EDIT: I forgot to mention that this issue only exists for INLINE editing, and editing via a popup window works.
PHP
<?php
// DataTables PHP library and database connection
include("lib/DataTables.php");
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst($db, 'tbl_BR_inspections', 'ID')
->fields(
Field::inst('tbl_BR_inspections.ID'),
Field::inst('tbl_BR_inspections.uniqueinspectionid')->set(FALSE),
Field::inst('tbl_BR_inspections.synchronizeddate')->set(FALSE),
Field::inst('tbl_lifecycle.UIID'),
Field::inst('tbl_lifecycle.cust_sentby')
)
->leftJoin('tbl_lifecycle', 'tbl_lifecycle.UIID', '=', 'tbl_BR_inspections.uniqueinspectionid')
->where('tbl_BR_inspections.synchronizeddate', '2017-06-23 13:21:00', '>')
->process($_POST)
->json();
JS
var editor = new $.fn.dataTable.Editor({
ajax: 'php/table.tbl_lifecycle.php',
table: '#tbl_lifecycle',
fields: [
{
name: "tbl_BR_inspections.ID", //attempted solution taken from forum post
type: "hidden"
},
{
label: "L.UIID:",
name: "tbl_lifecycle.UIID"
},
{
label: "I.UIID:",
name: "tbl_BR_inspections.uniqueinspectionid"
},
{
label: "Sync Date:",
name: "tbl_BR_inspections.synchronizeddate"
},
{
label: "cust_sentby:",
name: "tbl_lifecycle.cust_sentby"
}
]
});
// the below section control the table fields themselves (not the fields in the editor popup window)
var table = $('#tbl_lifecycle').DataTable({
ajax: 'php/table.tbl_lifecycle.php'
, columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
}
, {data: "tbl_BR_inspections.ID"}
, {data: "tbl_BR_inspections.uniqueinspectionid"}
, {data: "tbl_BR_inspections.synchronizeddate"}
, {data: "tbl_lifecycle.UIID"}
, {data: "tbl_lifecycle.cust_sentby"}
]
, keys: {
columns: ':not(:first-child)',
editor: editor
}
, select: {
style: 'os'
, selector: 'td:first-child'
// , blurable: true
}
, paging: true
, dom: 'Bfrtip'
, buttons: [
{extend: "create", editor: editor}
, {extend: "edit", editor: editor}
, {extend: "remove", editor: editor}
]
});
Answers
I suspect it is two things here:
tbl_lifecycle.UIID
parameter as you mentioned.submit
option offormOptions.inline
set to beallIfChanged
to submit all values from the row - including the UIID.Does it work if you click the Edit button with the above rather than use the key focusing?
Allan