How can I refer to a specific data in a row?
How can I refer to a specific data in a row?
I am testing the use of the DataTable for the first time, everything was regularly fine until I want to modify, I am testing the edit button but it does not refer to the id of the row I want to edit and this causes my Edit view to give me an error.
I tried using Ajax but it goes straight to the view with HTTP, and it marks an error.
This is my Ajax for body of my DataTable:
$('#lista').DataTable({
columns: [
{ title: "id", data:"idMarcas" },
{ title: "Marca", data:"Marcas" },
{ title: "Activo", data: "Activo" },
In the end I chose to use this, my button Eliminar is Ok but my button Edit not:
{
defaultContent:
"<div class='text-center'><div class='btn-group'><button class='btn btn-primary btn-sm btnEdit'><a class='toBoton' href='ModificarMarca?idMarcas=#idMarcas'>Editar</a></button><button class='btn btn-danger btn-sm btnBorrar'>Eliminar</button></div></div>"
}
I want to refer to { title: "id", data:"idMarcas" } in my href: href='ModificarMarca?idMarcas=#idMarcas'
Please,I need help
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Answers
Here is an example of row buttons using
columns.defaultContent
.http://live.datatables.net/xijecupo/1/edit
It uses delegated events a described in this example.
If you still need help please provide a link to your page or a running test case showing the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin