Editor and datetable in different files

Editor and datetable in different files

hugomeanahugomeana Posts: 18Questions: 0Answers: 0
edited February 2013 in General
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!

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    > I have a datetable, with a Editor in FILE_1.php and serverside PHP in FILE_2.php.

    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
  • hugomeanahugomeana Posts: 18Questions: 0Answers: 0
    I add the DT_RowId, but the editor doesn´t works...

    $row["DT_RowId"] = "row_$x";
    $output['aaData'][] = $row;

    How I do it?
  • hugomeanahugomeana Posts: 18Questions: 0Answers: 0
    After I add the DT_Row_Id parameter, when I remove a row, The firebug show me this parameters:

    action remove
    data[] row_3
    id
    table

    But the row doesnt´t remove, Why??

    Thank you.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Just an update for anyone else reading this, the issue was related to the database ID not being used for DT_RowId.

    Allan
This discussion has been closed.