开发者

DataTables plugin using jQuery to add a column in the table of a button

开发者 https://www.devze.com 2023-03-21 06:37 出处:网络
I am using DataTablesPlugin but I want to add a column with buttons and another that has a link. I try to make the button as follows:

I am using DataTablesPlugin but I want to add a column with buttons and another that has a link.

I try to make the button as follows:

var eliminar = document.createElement ('button')

eliminar.type = 'button';

var imagen = document.createElement ('img');

imagen.src = 'prueba.png';

eliminar.appendChild (imagen);

  $ ('# example'). dataTable (). fnAddData ([
number,
name,
address,
eliminar
]);

BUT MAKE THE FOLLOWING ERROR开发者_JAVA百科:

[object HTMLButtonElement]

The variables number, name, and address if shown in the table that are strings and were taken from a json.

I have read http://www.datatables.net/release-datatables/examples/plug-ins/html_sort.html but do not quite understand.

Could anyone help me solve this? Thanks and sorry I am new to java script and jquery,


I am not sure this will help with your problem, but there are two sytax problems I can see with your code:

var eliminar = document.createElement ('button')

is missing a semicolon at the end.

$ ('# example'). dataTable (). fnAddData ([

has spaces where no spaces should be.

$ ('#example').dataTable().fnAddData ([

The space character is not valid in IDs JavaScript. If your table actually has an ID with a leading space, you should delete that.

0

精彩评论

暂无评论...
验证码 换一张
取 消