Update a value in a specific column of my row
Update a value in a specific column of my row
Using the example given here https://editor.datatables.net/examples/simple/inTableControls.html I was able to get edit and delete links in my table and when clicking on them i either get the editor model popup to edit data ot the delete dialog. All works well. This is done by the following code
/*start code for inline buttons*/
// Edit record
$('#users').on( 'click', 'a.editor_edit', function (e) {
e.preventDefault();
editor
.title( 'Edit record' )
.buttons( { "label": "Update", "fn": function () { editor.submit() } } )
.edit( $(this).closest('tr') );
} );
// Delete a record
$('#users').on( 'click', 'a.editor_remove', function (e) {
e.preventDefault();
editor
.title( 'Edit record' )
.message( "Are you sure you wish to delete this row?" )
.buttons( { "label": "Delete", "fn": function () { editor.submit() } } )
.remove( $(this).closest('tr') );
} );
/*end code for inline buttons*/
What I am trying to get done is instead of deleting the row on delete in need to update the value of a column named status in my db and set that value to 2 and then redraw the table. Any suggestions?
This question has an accepted answers - jump to answer
Answers
Rather than using the
remove()
method, as you have done on line 20, you would useedit()
. You would then use the API to set the value you want (field().val()
) and then submit the form (submit()
).You might find this example useful.
Allan
That did it fantastic thanks