Simple left join not populating select field
Simple left join not populating select field
Simple left join with select field. In bubble the select field is empty, In inline I get error 11. I have read error 11 and add the editField but still does not work.
Using editor 1.5.1
SQL
SELECT ReportGroup.reportGroupID, ReportGroup.reportGroupName, ReportGroup.reportGroupDescr,
MBRROLE_FEATURE.ROLEFEATURE_ID, MBRROLE_FEATURE.NAME
FROM ReportGroup as ReportGroup
LEFT JOIN MBRROLE_FEATURE
ON ReportGroup.reportGroupRoleID = MBRROLE_FEATURE.ROLEFEATURE_ID
HTML
<table id="reportGroupedit" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>GROUP ID</th>
<th>GROUP NAME</th>
<th>ROLE</th>
<th>DESCRIPTION</th>
</tr>
</thead>
</table>
$('#reportGroupedit').DataTable( {
"paging": false,
"scrollCollapse": true,
"scrollY": "20em",
"ScrollX": "100%",
dom: "BfTrtip",
ajax: "/../../login/mysql/crudReportGroup.php",
columns: [
{ data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: "ReportGroup.reportGroupID" },
{ data: "ReportGroup.reportGroupName" },
{ data: "MBRROLE_FEATURE.NAME", editField: 'MBRROLE_FEATURE.ROLEFEATURE_ID'},
{ data: "ReportGroup.reportGroupDescr" }
],
order: [ 1, 'asc' ],
select: {
style: 'os',
selector: 'td:first-child'
},
buttons: [
{ extend: "create", editor: reportGroup_Editor },
{ extend: "edit", editor: reportGroup_Editor },
{ extend: "remove", editor: reportGroup_Editor }
]
});
reportGroup_Editor = new $.fn.dataTable.Editor( {
ajax: {
url: "/../../login/mysql/crudReportGroup.php",
},
table: "#reportGroupedit", //HTML table not sql table
fields: [ {
label: "GROUP ID: ",
name: "ReportGroup.reportGroupID",
type: "readonly",
attr: {
placeholder: "System generated ID number (Readonly)",
}
}, {
label: "GROUP NAME: ",
name: "ReportGroup.reportGroupName"
}, {
label: "ROLE FEATURE NAME: ",
name: "ReportGroup.reportGrouproleID",
type: "select"
}, {
label: "DESCRIPTION: ",
name: "ReportGroup.reportGroupDescr",
type: "textarea"
}
],
i18n: {
create: {
title: "Create New Role Feature",
},
edit: {
title: "Edit Role Feature",
},
remove: {
title: "Delete Role",
confirm: {
1: "Are you sure you wish to delete the checked Feature?",
}
}
},
display: 'jqueryui',
formOptions: {
main: {
onReturn: 'none'
}
}
});
PHP
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\join,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
Editor::inst($db)
->table("ReportGroup")
->pkey('reportGroupID')
->fields(
Field::inst( 'ReportGroup.reportGroupID' ),
Field::inst( 'ReportGroup.reportGroupName' )->validator( 'Validate::notEmpty' ),
Field::inst( 'ReportGroup.reportGroupDescr' ),
Field::inst( 'ReportGroup.reportGroupRoleID')
->options('MBRROLE_FEATURE', 'MBRROLE_FEATURE.ROLEFEATURE_ID', 'MBRROLE_FEATURE.NAME'),
Field::inst( 'MBRROLE_FEATURE.NAME')
)
->leftJoin("MBRROLE_FEATURE",'ReportGroup.reportGroupRoleID','=', 'MBRROLE_FEATURE.ROLEFEATURE_ID')
->process( $_POST )
->json();
AJAX load
{
"data":[
{
"DT_RowId":"row_1",
"ReportGroup":
{
"reportGroupID":"1",
"reportGroupName":"Admin",
"reportGroupDescr":"",
"reportGroupRoleID":"101"
},
"MBRROLE_FEATURE":{
"NAME":"RPTGRP_ADMIN"
}
},
{
"DT_RowId":"row_2",
...
I understand I have a syntax error but I can not find it. Any help would be-helpful
Answers
I think you actually want your column definition to be:
i.e. set
editField
to be the name of the field that you want to edit the value of.Allan
The change fixed the inline editing.
I fixed the empty select list. Missed spelled field name it should be ReportGroup.reportGroupRoleID and I had ReportGroup.reportGrouproleID.
thanks for your help
okay got the webpage to look correct but now none of the edit command works
New console.log
edit console.log