Copy row data in context menu

Copy row data in context menu

Igorski88Igorski88 Posts: 25Questions: 8Answers: 0
edited November 2019 in Free community support

The title says it all. I have read through 90% of the forums on this site. I can't find an example of this. All I can think of is to us the button().trigger() Method. But I feel like that's a cheap way to do it.

Here's what I have:

$('#CustomTransactionsDataTable tbody').on('mousedown', 'tr', function (e) {
                var table = $('#CustomTransactionsDataTable').DataTable();
                var data = table.row(this).data();
                var row = table.row(this);

                if (e.button == 2) {//This is spacific to the right click
                    //alert('You RightClicked on ' + data.Title + '\'s row');

                    $.contextMenu({
                        selector: '.table',
                        callback: function (key, options) {

                            if (key == "copy") {


                            };

                            if (key == "Delete") {

                                editor
                                    .title('Delete Selected Expense')
                                    .buttons('Confirm delete')
                                    .message('Are you sure you want to delete the selected expense?')
                                    .remove(row); // If this returns an integer then it will delete the row index but if its a string then it will look for ID

                            };

                        },
                        items: {
                            "copy": { name: "Copy", icon: "copy" },
                            "Duplicate": { name: "Duplicate Expense", icon: "copy" },
                            "sep1": "---------",
                            "Delete": { name: "Delete the Expense", icon: "delete" }

                        }
                    });

                    return false;

                }

            });

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.