action: remove

action: remove

snapshotsnapshot Posts: 5Questions: 0Answers: 0
edited March 2014 in Editor
Can anyone tell me how i can delete a row from the table. The following Form Data is sent when i click on Delete:

action:remove
table:
id:
data[]:

There is no data. How can i send my own ID so that the data can be deleted from the DataBase?

[code]
$('#cashierTable').dataTable( {
"destroy": true,
"sAjaxSource": "/DataWarehouseWeb-1.0-SNAPSHOT/RetailSnapshot/plugins/datatables/sources/employeeRead.jsp?Whs=" + document.getElementById("whs_id").value,
"info": false,
"bDeferRender": true,
"bAutoWidth": true,
"scrollY": 100,
"scrollCollapse":false,
"paging" : false,
"order": [ 2, 'asc' ],
"jQueryUI": true,
"jQueryUI": true,
"columns": [
{"sName":"DS Id", "sTitle": "DS Id", "searchable" : true, "data": "dsId", "bVisible": true},
{"sName":"cId", "sTitle": "cId", "searchable" : true, "data": "cashierId", "bVisible": true},
{"sName":"First Name", "sTitle": "First Name", "searchable" : true, "data": "firstName"},
{"sName":"Last Name", "sTitle": "Last Name", "searchable" : true, "data": "lastName"},
{"sName":"Employee #", "sTitle": "Employee #", "searchable" : true, "data": "employeeNumber"},
{"sName":"Whs #", "sTitle": "Whs #", "searchable" : true, "data": "whs_num"},
{"sName":"Published", "sTitle": "Published", "searchable" : true, "data": "published"}
],

"oTableTools": {
"sRowSelect": "single",
"aButtons": [

{ "sExtends": "editor_create", "editor": editor_B, "sButtonText":"Add New Cashier","title":"Add New Cashier"},
{ "sExtends": "editor_edit", "editor": editor_B },
{ "sExtends": "editor_remove", "editor": editor_B },
/*{ "sExtends": "editor_create", "sButtonText": "Return to Over Short ==>" }*/
],
},
"dom" : '<"H"fT "cec"><"clear"><"F"ip"clear">'

} );
[/code]

[code]
editor_B = new $.fn.dataTable.Editor( {
"ajaxUrl": "/DataWarehouseWeb-1.0-SNAPSHOT/RetailSnapshot/plugins/datatables/sources/employeeEdit.jsp",
"domTable": "#cashierTable",
"type": "post",
"fields": [
{
"label": "DS ID",
"name": "dsId",
"type": "text"
},
{
"label": "Published",
"name": "published",
"type": "checkbox",
"default": "true",
"ipOpts": [
{ "label": "Published", "value": "true" }
]
},
{
"label": "Cashier Id",
"name": "cashierId",
"type": "text"
},
{
"label": "First Name",
"name": "firstName",
"type": "text"
},
{
"label": "Last Name",
"name": "lastName",
"type": "text"
},
{
"label": "Employee #",
"name": "employeeNumber",
"type": "text"
},
{
"label": "Whs Nr",
"name": "whs_num",
"type": "text",
"default": document.getElementById("whs_id").value
}
]
} );
[/code]

Replies

  • allanallan Posts: 61,725Questions: 1Answers: 10,108 Site admin
    The idSrc option might be appropriate here: https://editor.datatables.net/options/#idSrc . Is the id in the data source object that DataTables sees? If so, then set `idSrc` to match that parameter and it will be sent to the server as part of the delete.

    Thanks,
    Allan
  • snapshotsnapshot Posts: 5Questions: 0Answers: 0
    Solved. Is what i needed was "idSrc" : "cashierId",
  • cfdudecfdude Posts: 4Questions: 0Answers: 0
    Allan, in the same example above, is there a way to send back more than just the idSrc for the selected row to delete? I'd like to send back all the field values for that row.
  • allanallan Posts: 61,725Questions: 1Answers: 10,108 Site admin
    You would need to use the `onPreSubmit` event in order to send back more information to the server:

    [code]
    editor.on( 'onPreSubmit', function ( e, data, action ) {
    if ( action === 'remove' ) {
    d.extra = 1; // etc
    }
    } );
    [/code]

    onPreSubmit documentation is available here: https://editor.datatables.net/api/#onPreSubmit .

    Allan
This discussion has been closed.