How to report using only 5 columns?
How to report using only 5 columns?

Hello, DataTablers!
I have buttons and a table with edit and delete buttons in the 6 column
So, trying to get report in Excel I have like this
Name Position Office Age Salary
Tatyana Fitzpatrick Regional Director London 19 385750 Edit Delete
Shou Itou Regional Marketing Tokyo 20 163000 Edit Delete
Caesar Vance Pre-Sales Support New York 21 106450 Edit Delete
What I need to write in my code to have only
Name Position Office Age Salary
Tatyana Fitzpatrick Regional Director London 19 385750
Shou Itou Regional Marketing Tokyo 20 163000
Caesar Vance Pre-Sales Support New York 21 106450
My current code:
"ajax": {
"url": "/Employee/GetData",
"type": "GET",
"datatype": "json"
},
"columns": [
{ "data": "Name" },
{ "data": "Position" },
{ "data": "Office" },
{ "data": "Age" },
{ "data": "Salary" },
{"data":"EmployeeID" , "render" : function (data) {
return "<a class='btn btn-default btn-sm' onclick=PopupForm('@Url.Action("AddOrEdit","Employee")/" +
data + "')><i class='fa fa-pencil'></i> Edit</a><a class='btn btn-danger btn-sm' style='margin-left:5px' onclick=Delete(" +
data + ")><i class='fa fa-trash'></i> Delete</a>";
},
"orderable": false,
"searchable":false,
"width":"160px"
}
],
"dom": "Bfrtip",
"buttons": ['copy', 'excel','csv','pdf','print'],
Answers
This example will show how to choose the columns for export:
https://datatables.net/extensions/buttons/examples/print/columns.html
Kevin
Well..
The vision of my table - without my last column after I ve used
dom: 'Bfrtip',
buttons: [
{
extend: 'print',
exportOptions: {
columns: ':visible'
}
},
'colvis'
],
columnDefs: [{
targets: 5,
visible: false
}],
And my report is still the same(
...
The example I posted discusses using
column-selector
to choose the columns. Take a look at all the options they are very useful. You can use more than justcolumns: ':visible'
. Maybe this example is better:https://datatables.net/extensions/buttons/examples/html5/columns.html
Kevin