Help with Delete from database
Help with Delete from database
I have searched through the forum and have come across solutions that indicate Ajax must be used to delete a datatable record from my database but I'm not sure where or how to implement such a function as I'm not a Javascript or Ajax expert. Basically, what would I need to do with the following code in order to access my ID database column and delete from the database? Thanks.
[code]
$(document).ready( function () {
var oTable = $('#example').dataTable().makeEditable({
sUpdateURL: "UpdateData.cfm",
sAddURL: "AddData.cfm",
sDeleteURL: "DeleteData.cfm"
});
} );
[/code]
[code]
$(document).ready( function () {
var oTable = $('#example').dataTable().makeEditable({
sUpdateURL: "UpdateData.cfm",
sAddURL: "AddData.cfm",
sDeleteURL: "DeleteData.cfm"
});
} );
[/code]
This discussion has been closed.
Replies
Allan
Allan
{code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "server_processing.php",
"sPaginationType": "full_numbers",
"fnDrawCallback": function () {
//alert( 'Number of rows: '+ this.fnGetNodes() );
$('td', this.fnGetNodes()).editable( 'editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
//alert( 'Got ID of: '+oTable.fnGetData( this.parentNode )[0] );
return { "row_id": oTable.fnGetData( this.parentNode )[0],
"column": oTable.fnGetPosition( this )[2]};
},
"height": "14px"
} );
}
});
});
[/code]
As for editable_ajax.php - that would simply to an UPDATE on the DB based on the data that is sent to it (which you can see using Firebug). My example doesn't do that, it just does an echo - again because I didn't want to write anything server-side specific.
My editable demo is quite different from the editable plug-in from Jovan though. Which is it that you are trying to use? My demo doesn't include delete options for example - you would need to add them. There is also this blog post which you might find interesting: http://datatables.net/blog/Inline_editing
Allan