I'm trying to add a custom button performing the action defined by R-function to my datatable. I've used the same list of options in my R code as in Javascript code in Datatables manual, but it doesn't work.
Here is a code from Datatables manual:
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
{
text: 'My button',
action: function ( e, dt, node, config ) {
alert( 'Button activated' );
}
}
]
} );
} );
And here is my code in R:
require(DT)
DT::datatable(iris,
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = list(
list(
text = 'test',
action = print('1')
)
)
)
)
Executing it I've received an error:
Error in if (extend != "collection") extend else listButtons(cfg) :
argument is of length zero