Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81999

Join / order

$
0
0
Hi,
I have two tables:

tblExerciseEquipment and tblLanguages. The latter table is for internationalization.

So 1 piece of equipment (e.g. "ball") could be translated into n languages.

The link between the tables is tblExerciseEquipment.f_LanguageID and tblLanguages.LanguageID

On the SERVER SIDE, I have the following code:

$editor = Editor::inst( $db, 'tblExerciseEquipment' )
->fields(
Field::inst( 'EquipmentName' )->validator( 'Validate::required' ),
Field::inst( 'f_LanguageID' )->validator( 'Validate::required' )
)
->join(
Join::inst('tblLanguages','array')
->join('f_LanguageID','LanguageID')
->fields(
Field::inst( 'LanguageID' )->validator( 'Validate::required' ),
Field::inst( 'LName' ))
);

$out = $editor
->pkey('EEquipmentID')
->process($_POST)
->data();

if ( !isset($_POST['action']) ) {
// Get department details
$out['tblLanguages'] = $db
->select( 'tblLanguages', 'LanguageID as value, LName as label' )
->fetchAll();

}

On the CLIENT SIDE, I have:

var editor;

$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "ajax_content_exerciseEquipment.php",
"domTable": "#tblExerciseEquipment",
"fields": [ {
"label": "Language:",
// The 'id' value from the property is used to set the value
// of the select list.
"name": "f_LanguageID",
"type": "select"
}, {
"label": "Equipment name:",
// 'name' here will generate an array of the 'id' properties from
// the access parameter for the row's data and use that to enable
// the correct checkboxes.
"name": "EquipmentName"
}
]
} );

$('#tblExerciseEquipment').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "ajax_content_exerciseEquipment.php",
"aoColumns": [
{
// Use the 'name' property from the 'dept' object in the
// JSON. It might not be set, so we also provide a default.
"mData": "tblLanguages.LName",
"sDefaultContent": ""
},
{ "mData": "EquipmentName" }

],
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
},
"fnInitComplete": function ( settings, json ) {
editor.field('f_LanguageID').update( json.tblLanguages );
}
} );
} );

When I submit the form, I receive the following error:

Undefined index: tblLanguages in /Users/xxx/functions/datatables/Editor/Join.php on line 474

#

What am I doing wrong here? I have been SQL programming since 1998, but am rather confused with the order of the statements that are required here.

});

Viewing all articles
Browse latest Browse all 81999

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>