Editor and datetable in different files
Editor and datetable in different files
Hello,
I have a datetable, with a Editor in FILE_1.php and serverside PHP in FILE_2.php.
The serverside is work correctly, but the editor, when I want to remove or edit a row, it dont work. I see this JSON in firebug:
action remove
data[]
id
table
if i edit, this JSON:
action edit
data[]
id
table
Why the id value is empty?
This is my PHP editor:
[code]
include( "lib/DataTables.php" );
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
// Formulario de edicion
$editor = Editor::inst( $db, 'orders', 'id' )
->fields(
Field::inst( 'id' ),
Field::inst( 'ticket_id' )
);
$out = $editor
->process($_POST)
->data();
echo json_encode( $out );
[/code]
And this is my JS editor:
[code]
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "table.table_editor.php",
"domTable": "#table",
"fields": [
{
"label": "ID",
"name" : "id",
"type": "text"
},
{
"label": "Ticket ID",
"name" : "ticket_id",
"type": "text"
}
]
} );
[/code]
Thank you!
I have a datetable, with a Editor in FILE_1.php and serverside PHP in FILE_2.php.
The serverside is work correctly, but the editor, when I want to remove or edit a row, it dont work. I see this JSON in firebug:
action remove
data[]
id
table
if i edit, this JSON:
action edit
data[]
id
table
Why the id value is empty?
This is my PHP editor:
[code]
include( "lib/DataTables.php" );
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
// Formulario de edicion
$editor = Editor::inst( $db, 'orders', 'id' )
->fields(
Field::inst( 'id' ),
Field::inst( 'ticket_id' )
);
$out = $editor
->process($_POST)
->data();
echo json_encode( $out );
[/code]
And this is my JS editor:
[code]
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "table.table_editor.php",
"domTable": "#table",
"fields": [
{
"label": "ID",
"name" : "id",
"type": "text"
},
{
"label": "Ticket ID",
"name" : "ticket_id",
"type": "text"
}
]
} );
[/code]
Thank you!
This discussion has been closed.
Replies
With the latest Editor, you don't need to do this - the Editor PHP classes will automatically detect and handle server-side processing requests.
Allan
$row["DT_RowId"] = "row_$x";
$output['aaData'][] = $row;
How I do it?
action remove
data[] row_3
id
table
But the row doesnt´t remove, Why??
Thank you.
Allan