I'm using DataTables
(datatables.net) and I would like to add a context menu to my table.
I found jQuery contextMenu and also description in the DataTables
forum on how somebody implemented the context menu.
But it seems that at least the DataTables
I'm currently using (1.10) has evolved quite much.
I have not information about the Context Menu
plugin. (meaning what version was using in this forum post and what I have downloaded).
If I use it as described in the forum post and adapt it to 1.10 (to my humble knowledge) I'm comming to this
var myTable = $("#myTable ").DataTable( {
"drawCallback": function( settings ) {
$("#myTable tbody tr").contextMenu(
{
menu: 'myMenu'},
function( action, el, pos ) {
var aData = myTable.GetData( el.context );
}
);
}
} );
But executing this code will give me this error:
Uncaught Error: No selector specified in jquery.contextMenu.js:1273
Has anybody recently implementet context menu to DataTable
1.10?
I have just see this question, and would like to answer it because I was looking for a solution for this.
Here you have a demo using jquery.ui-contextmenu: DEMO
I use jquery.ui in addition, hope this won't be a problem for you.
It is integrated with functions fnFilter()
and fnFilterClear()
, so you can filter data using right-click.
Thanks!
UPDATE: DataTables 1.10 API style!
Removed fnFilter()
and fnFilterClear()
and use the new search()
API method.
DEMO :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With