How to display seleceted table row/column data in remove confirmation message
How to display seleceted table row/column data in remove confirmation message
Tony_Bartolucci
Posts: 2Questions: 1Answers: 0
Am using datatable editor
$(document).ready(function () {
editor = new $.fn.dataTable.Editor( {
"ajax": {
edit: {
type: 'POST',
url: '${contextPath}/updateUser'
},
remove: {
type: 'POST',
url: '${contextPath}/deleteUser'
}
},
i18n: {
remove: {
confirm: {
1: "Confirm deletion of record."+'${contextPath}'+delName
}
}
},
"table": "#example",
} );
And datatable with table tools
tableTools: {
sRowSelect: "os",
aButtons: [
{ sExtends: "editor_edit", editor: editor },
{ sExtends: "editor_remove", editor: editor }
]
},
And used
editor
.on( 'initRemove', function ( e, data, action ) {
var oTT = TableTools.fnGetInstance( 'example' );
var aData = oTT.fnGetSelectedData();
delName=aData[0].userName;
alert("a ="+delName);
} )
how to display userName info in delete confirmation meassage?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi Tony,
It looks like you are on the correct path with
initRemove
and accessing the selected data. The one missing step is to usemessage()
to display the message e.g. you might have the following where you currently have thealert()
:If you'd like to refine it further you can use the
data
parameter being passed intoinitRemove
rather than needing to use the rather messy TableTools API (I'm going to be replacing it soon!):Note the use of the array index
[0]
- this is becauseremove()
can be called on multiple rows.Regards,
Allan
Thanks a lot Allan. It worked perfectly :)