Add href and img with fnAddData
Add href and img with fnAddData
fernandopaiva
Posts: 6Questions: 1Answers: 0
Hello all
I am trying add a href and img in my DataTable but in the column show only [object Object]
I'm trying below
[code]
function addRegistrosTabela(output){
var obj = output;
var links = [];
for(i in obj){
var editar = $('',{
title: 'Edit',
href: "../controls/YCurriculumController.php?action=editarCurriculum&id=" + obj[i].id_curriculum
}).append($('')
.attr("src","../imagens/editIcon.png"));
var deletar = $('',{
title: 'Delete',
href: "../controls/YCurriculumController.php?action=deletarCurriculum&id=" + obj[i].id_curriculum
}).append($('')
.attr("src","../imagens/deleteIcon.png"));
$('#idTabela').dataTable().fnAddData([
obj[i].id_curriculum,
obj[i].nome,
obj[i].cpf,
obj[i].endereco,
obj[i].bairro,
obj[i].cidade,
obj[i].fone1,
obj[i].celular,
obj[i].email,
obj[i].cargo,
editar, //here show [object]
deletar //here show [object]
]);
[/code]
I am trying add a href and img in my DataTable but in the column show only [object Object]
I'm trying below
[code]
function addRegistrosTabela(output){
var obj = output;
var links = [];
for(i in obj){
var editar = $('',{
title: 'Edit',
href: "../controls/YCurriculumController.php?action=editarCurriculum&id=" + obj[i].id_curriculum
}).append($('')
.attr("src","../imagens/editIcon.png"));
var deletar = $('',{
title: 'Delete',
href: "../controls/YCurriculumController.php?action=deletarCurriculum&id=" + obj[i].id_curriculum
}).append($('')
.attr("src","../imagens/deleteIcon.png"));
$('#idTabela').dataTable().fnAddData([
obj[i].id_curriculum,
obj[i].nome,
obj[i].cpf,
obj[i].endereco,
obj[i].bairro,
obj[i].cidade,
obj[i].fone1,
obj[i].celular,
obj[i].email,
obj[i].cargo,
editar, //here show [object]
deletar //here show [object]
]);
[/code]
This discussion has been closed.
Replies
Allan
How I building the HTML string with my node ?
thanks
Allan
I am trying this.
[code]
//html
ID
Actions
//javascript
$(document).ready(function(){
var i = 0;
while(i < 10){
var edit = "Edit";
$("#mytable > tbody").append("");
$("#mytable > tbody").append("" + i + "");
$("#mytable > tbody").append("" + edit + "");
$("#mytable > tbody").append("");
i++;
}
});
[/code]
thanks
The ability to add TR nodes using `row.add( node )` will be available in v1.10.
Allan
thanks Allan