Buttons and Individual column searching

Buttons and Individual column searching

MarekAdamMarekAdam Posts: 30Questions: 9Answers: 1
edited September 2020 in Free community support

I want to use buttons and Individual column searching (text inputs+select, all in tfoot). I set up buttons, select inputs and text in cols where i want. When i add text inputs, the buttons are gone. How i can use both at same time? Buttons in header and Individual column searching in tfoot?

I use code like in axamples. There is no errors in console. Table is working. When i deleting Individual column searching buttons are visible. I dont want put all my code bacause js file has more than 400 lines (nice table :D)

    // Setup - add a text input to each footer cell
    $('#example tfoot th').each( function () {
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );

//buttons
 buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor },
            'colvis', 'print',  'copy', 'excel',
            {extend:  'pdf',  orientation: 'landscape', pageSize : 'A0',}
        ]

                // Apply the search
                this.api().columns().every(function () {
                    var that = this;

                    $('input', this.footer()).on('keyup change clear', function () {
                        if (that.search() !== this.value) {
                            that
                                .search(this.value)
                                .draw();
                        }
                    });
                });

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

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,160Questions: 26Answers: 4,921

    Its hard to say from your code snippets. Looks like you could be missing a comma after the ] on line 14. I'm assuming that you cut out a bunch of code thus not showing the us of option initComplete.

    Please post a link to your page or a running test case showing the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • MarekAdamMarekAdam Posts: 30Questions: 9Answers: 1

    Thanks for fast answer. Sorry for mistake with Syntax highlighting. Im new :)

    Code is working fine. There is no errors in console. There is logical problem.
    When i erase

        $('#example tfoot th').each( function () {
            var title = $(this).text();
            $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
        } );
    

    The buttons reappear

    Is there any example with buttons and Individual column searching in one table?

    I cant put my code in live.datatables.net, my data for table base on json from mysql. I can put js file in JS bin.

  • kthorngrenkthorngren Posts: 21,160Questions: 26Answers: 4,921
    Answer ✓

    I took this example and added buttons to it here:
    http://live.datatables.net/xiyubafi/1/edit

    https://datatables.net/examples/api/multi_filter_select.html

    I cant put my code in live.datatables.net, my data for table base on json from mysql.

    The problem you are having is not data specific. You can build an example where you like as long as it shows the issue. In fact you can update mine if you like. Or you can start from this basic Editor example if you also want to show your editor buttons.
    http://live.datatables.net/guwafemu/1/edit

    Kevin

  • MarekAdamMarekAdam Posts: 30Questions: 9Answers: 1

    Ok, i feel stupid :D i will check differences betwen my code and your example. Write when i will find issue.

    Thank you very much for your help :)

  • MarekAdamMarekAdam Posts: 30Questions: 9Answers: 1
    edited September 2020

    on your example my code is working
    http://live.datatables.net/qajefiwi/1/edit?js,output
    ehhh... it will be loooong evening...

  • MarekAdamMarekAdam Posts: 30Questions: 9Answers: 1

    it start working
    i dont know why

    you can close topic

This discussion has been closed.