【发布时间】:2019-04-20 10:59:56
【问题描述】:
我正在尝试将执行 R 函数定义的操作的自定义按钮添加到我的数据表中。我在 R 代码中使用了与 Datatables manual 中的 Javascript 代码相同的选项列表,但它不起作用。
这是来自Datatables manual的代码:
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
{
text: 'My button',
action: function ( e, dt, node, config ) {
alert( 'Button activated' );
}
}
]
} );
} );
这是我在 R 中的代码:
require(DT)
DT::datatable(iris,
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = list(
list(
text = 'test',
action = print('1')
)
)
)
)
执行它我收到一个错误:
Error in if (extend != "collection") extend else listButtons(cfg) :
argument is of length zero
【问题讨论】:
标签: r datatables dt