Using custom delete button but it required an ID column which I do not want to show...
Using custom delete button but it required an ID column which I do not want to show...
Hello,
I am CodeIgnitor to build my application. I am also using the CodeIgniter DataTable Library by Paul Zepernick.
The problem is, in order for the custom code, courtesy of CodeWife, it requires that the ID column is used. Here is her code (modified slightly to suite my needs):
$("body").on("click", "#remove", function(event){
var answer = confirm("Are you sure you wish to delete this customer?")
if (answer) {
var pid = $(this).closest('tr').children('td:nth(0)').text();
$.ajax({
type: "POST",
url: "/customers/delete",
datatype: "html",
data: {
id: pid
},
success: function(data)
{
$('#demo-dynamic-tables-2').DataTable().ajax.reload();
alert(data);
}
});
}
});
Basically I want to replace this line of code:
var pid = $(this).closest('tr').children('td:nth(0)').text();
With the customer_id value for that row. that way I don't have to show the column...
Is there a way to do this?
This question has an accepted answers - jump to answer
Answers
You could try:
That unfortunitely still required me to have a column. I am new to javascript and am trying to find a different route as i do not want the customer_id visable to the customer (the unique id).
Is there a way to push the id via an onclick event? For instance i render the delete button with onclick=delete(45) where 45 is that rows customer id.
I managed to figure out how to render all my other buttons to have the customer_id implemented into them, but the delete button still requires that ID to be a visable column so that the java script can grab it.
My id column is not visible and that works fine for me
Thank you very much, works like a charm.