Uncaught TypeError: Cannot read property 'type' of undefined
Uncaught TypeError: Cannot read property 'type' of undefined
Hello All.
For the life of me I'm unable to determine what is causing this issue. The datatable is fed via ajax, and this issue appears in dataTables.editor.js:1665 from chrome inspector when either submitting a new entry, or attempting to update an existing entry. I have 4 other editable datatables setup very similarly which don't have this problem. Essentially the edit box appears, with the current data in the field, but when you press submit notting happens, other than this js error occurring. The table is very minimal with only a single field, but there seems to be something very odd with the field itself:
[code]
$(document).ready(function(){
tagsEditor = new $.fn.dataTable.Editor( {
"domTable": "#masterTag-table",
"ajaxUrl": "../php/editable/tags.php",
"fields" : [
{
// Label is label in form, name is how to handle the field in code, and type is type of input / display of field
"label": "Tag:",
"name": "Tag",
"type": "text"
}
]
});
tagsTable = $('#masterTag-table').dataTable({
//"sScrollX": "100%",
"sScrollY": calcDataTableHeight(),
"sAjaxSource": "../php/editable/tags.php",
"bScrollCollapse": true,
"bJQueryUI": true,
"bPaginate": false,
"sDom": '<"table-header"ClTfiR>t',
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{"sExtends":"editor_create", "sButtonClass":"DTTT_button_create", "editor":tagsEditor},
{"sExtends":"editor_edit", "sButtonClass":"DTTT_button_edit", "editor":tagsEditor},
{"sExtends":"editor_remove", "sButtonClass":"DTTT_button_delete", "editor":tagsEditor},
{"sExtends": "copy"},
{"sExtends": "csv"},
{"sExtends": "pdf"},
{"sExtends": "print", "sInfo": "Print viewPlease use your browser's print function to print this table. Press escape when finished."}
],
"sSwfPath": "../swf/copy_csv_xls_pdf.swf"
},
"aoColumns": [
{
"mRender": function ( data, type, row ) { return data.replace(/&/g,'&').replace(//g,'>') ;},
"mData": "Tag",
"sWidth": "350px"
}
]
});
});
[/code]
the mRender code is due to a display issue where '<>' symbols are stripped from the row elements.
Here is tags.php:
[code]
//
//// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
$editor = Editor::inst( $db, 'MasterTags',"Tag" ) // these are the db connection, the table name, and the primary key for that table.
->fields(
Field::inst( 'Tag' )
);
$out = $editor
->process( $_POST )
->data();
echo json_encode($out);
[/code]
It appears to be pretty basic with only one column, but I just don't understand what would be causing this issue.
Thanks!
For the life of me I'm unable to determine what is causing this issue. The datatable is fed via ajax, and this issue appears in dataTables.editor.js:1665 from chrome inspector when either submitting a new entry, or attempting to update an existing entry. I have 4 other editable datatables setup very similarly which don't have this problem. Essentially the edit box appears, with the current data in the field, but when you press submit notting happens, other than this js error occurring. The table is very minimal with only a single field, but there seems to be something very odd with the field itself:
[code]
$(document).ready(function(){
tagsEditor = new $.fn.dataTable.Editor( {
"domTable": "#masterTag-table",
"ajaxUrl": "../php/editable/tags.php",
"fields" : [
{
// Label is label in form, name is how to handle the field in code, and type is type of input / display of field
"label": "Tag:",
"name": "Tag",
"type": "text"
}
]
});
tagsTable = $('#masterTag-table').dataTable({
//"sScrollX": "100%",
"sScrollY": calcDataTableHeight(),
"sAjaxSource": "../php/editable/tags.php",
"bScrollCollapse": true,
"bJQueryUI": true,
"bPaginate": false,
"sDom": '<"table-header"ClTfiR>t',
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{"sExtends":"editor_create", "sButtonClass":"DTTT_button_create", "editor":tagsEditor},
{"sExtends":"editor_edit", "sButtonClass":"DTTT_button_edit", "editor":tagsEditor},
{"sExtends":"editor_remove", "sButtonClass":"DTTT_button_delete", "editor":tagsEditor},
{"sExtends": "copy"},
{"sExtends": "csv"},
{"sExtends": "pdf"},
{"sExtends": "print", "sInfo": "Print viewPlease use your browser's print function to print this table. Press escape when finished."}
],
"sSwfPath": "../swf/copy_csv_xls_pdf.swf"
},
"aoColumns": [
{
"mRender": function ( data, type, row ) { return data.replace(/&/g,'&').replace(//g,'>') ;},
"mData": "Tag",
"sWidth": "350px"
}
]
});
});
[/code]
the mRender code is due to a display issue where '<>' symbols are stripped from the row elements.
Here is tags.php:
[code]
//
//// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
$editor = Editor::inst( $db, 'MasterTags',"Tag" ) // these are the db connection, the table name, and the primary key for that table.
->fields(
Field::inst( 'Tag' )
);
$out = $editor
->process( $_POST )
->data();
echo json_encode($out);
[/code]
It appears to be pretty basic with only one column, but I just don't understand what would be causing this issue.
Thanks!
This discussion has been closed.
Replies
Thanks,
Allan
Along with the code above, I also just for testing, created a new "Tags" SQL table that has both a tag column as well as an id which is the new primary ID, just to see if there was any issue with a string being an issue as the primary key, but it has the same issue. An image of the inspector window with the error is posted here:
http://oi44.tinypic.com/15naf0n.jpg
Essentially every time Update, New, or Delete buttons are pressed this error appears.
What's weird is that our project now has roughly 10 other datatables, with a lot more data and columns which don't have this issue.
Other than this issue editor has been very straight forward to implement!
Allan