我需要用来自服务器的 json、aaData
和 aoColumns
填充表格,但问题是我需要一个带有按钮的列。
我有这个代码
$('#divGrid').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>');
var results = result.split('@_@');
$('#example').dataTable({
"aaData": $.parseJSON(results[0]),
,
"aoColumns": $.parseJSON(results[1])
});
}
我的结果是
results[0] = "[["
jpa ","
SI ","
","
","
","
PADILLA ",1],["
sid ","
SI ","
","
","
","
MIRAMONTES ",2]]"
results[1] = [{
"sTitle": "UserName"
}, {
"sTitle": "ID_CENTRO_TRABAJO"
}, {
"sTitle": "rolName"
}, {
"sTitle": "dominio"
}, {
"sTitle": "recibeAlertas"
}, {
"sTitle": "NOMBRE"
}, {
"sTitle": "edit",
"fnRender": 'function(obj){ return ' < input type = 'button'
name = 'hola'
value = 'Play' > < /input>';}'}]"
但是我的控制台很干净,没有抛出任何错误。该值出现,但按钮未出现。
最佳答案
您在返回和封装属性中使用相同的单引号,对属性使用双引号
return '<input type="button" name="hola" value="Play">';
关于javascript - 使用 $.parseJson() datatables.js 添加 aocolumns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18551909/