0

I'm tring to have a csv download button and need to exclude a couple of columns from table.

I've found a exportOptions defines which columns should be exported. this option comes from jQuery datatalbles and table.column() method is likely to be used to select columns.

now I need to select certain columns, but I couldn't find out how with angular-datatables way.

anyone knows solution?

    <table dt-options="dtOptions" dt-column-defs="dtColumnDef">
        <thead>
            <tr>
                <th>hoo</th>
                <th>hoo</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>hoo</td>
                <td>hoo</td>
            </tr>
        </tbody>
    </table>



<script>
    // here is inside my controller

    $scope.dtOptions = DTOptionsBuilder
    .newOptions()
    .withDOM('tB')
    .withButtons([
    {
        text: 'download csv',
        extend: 'csv',
        exportOptions:
        {
            // columns: I neet to select certain columns here
            // wiht method like "table.columns(0)" mentioned in jQuery datatables document
            // but I don't know how in angular-datatables
        }
    }]);
</script>

I use angular-way to render table.

1
  • does anyone have a clew? Commented Nov 14, 2017 at 2:23

1 Answer 1

1

There is no difference between the angular way and a pure jQuery DataTable. And you do not need to access the table instance in exportOptions. What you need is to return a column selector; here are some examples (dont know exactly what you are trying to do) :

exportOptions: {
  columns: [0,4,5] //some columns by index
}
exportOptions: {
  columns: 'th' //any column
}
exportOptions: {
  columns: ['th:eq(1)', 'th:eq(5)'] //same as numbered array
}
exportOptions: {
  columns: 'th:not(:first)' //exclude the first column
} 
exportOptions: {
  columns: 'th:not(.no-export)' //exclude columns with class no-export
} 

etc.

Sign up to request clarification or add additional context in comments.

1 Comment

would this be the solution for the event handlers for on click on th !? or a next button click

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.