is others example have some features

is others example have some features

Ahmed321Ahmed321 Posts: 7Questions: 2Answers: 0

i use table have buttons to export and when i try add lengthMenu the export buttons hide
so i search about solve and it solved ( thanks)
but now i try to add code for sum column the search columns header stopped
so i hope any one send link for example for basic features for table
cose sure i need header search columns and need buttons for export data and lengthMenu and sum numer columns
thanks and appreciation for your support

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,132Questions: 26Answers: 4,918

    Sounds like a syntax error. Look in your browser's console for errors. Make sure you are separating the options (features) with a comma. If you still need help please provide a test showing what you have so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • Ahmed321Ahmed321 Posts: 7Questions: 2Answers: 0
    edited April 2021

    I concatenate this parts to can get table have
    - search box and lengthMenu
    - search header for coulumns
    - export buttons
    and it work good hope i can share it with you

            $(document).ready(function () {
                // Setup - add a text input to each footer cell
                $('#example thead tr').clone(true).appendTo('#example thead');
                $('#example thead tr:eq(1) th').each(function (i) {
                    var title = $(this).text();
                    $(this).html('<input type="text" placeholder="Search ' + title + '" />');
    
                    $('input', this).on('keyup change', function () {
                        if (table.column(i).search() !== this.value) {
                            table
                                .column(i)
                                .search(this.value)
                                .draw();
                        }
                    });
                });
    
                var table = $('#example').DataTable({
                    orderCellsTop: true,
                    fixedHeader: true,
                    dom: 'Blftrip',
                    buttons: [
                        'copy', 'csv', 'excel', 'pdf', 'print'
                    ],
                    lengthMenu: [
                        [10, 25, 50, -1],
                        ['10 rows', '25 rows', '50 rows', 'Show all']
    
                    ],
    

    but when i try add code for make sum for numer column every thing stopped

                        // Total over all pages
                        total = api
                            .column(5)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
    
                        // Total over this page
                        pageTotal = api
                            .column(5, { page: 'current' })
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            }, 0);
    
                        // Update footer
                        $(api.column(5).footer()).html(
                            '$' + pageTotal + ' ( $' + total + ' total)'
                        );
    

    thanks for your support

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 21,132Questions: 26Answers: 4,918
    Answer ✓

    Your second code snippet is incomplete. The footerCallback example provides the complete code. You need to use lines 3 through 35.

    Kevin

  • Ahmed321Ahmed321 Posts: 7Questions: 2Answers: 0

    I'm really so happy
    thank u so much

This discussion has been closed.