searchBuilder.columns not working with dom: 'Bfrtip'?

searchBuilder.columns not working with dom: 'Bfrtip'?

straetchstraetch Posts: 5Questions: 3Answers: 0

My first forum question.
Code with dom: 'Bfrtip',

searchBuilder: {
  columns: [3,4,5]
},

Everything works fine, except the modal shows all columns in the Data drop-down.
As an experiment I replaced dom: 'Bfrtip' by dom: 'Qlfrtip' ; now only the three columns are displayed, as expected.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    If you are not using dom: 'Qlfrtip' how are you initializing SearchBuilder?

    This test case shows using the above code with API initialization and it limits to the columns specified:
    http://live.datatables.net/girajobe/1/edit

    Please provide a link to your page or update the test case to show the issue.

    Kevin

  • straetchstraetch Posts: 5Questions: 3Answers: 0

    My JQuery skills are limited. I made my code by assembling code snippits from the excellent examples and the forum posts.
    This was a section of my code with a button to activate searchBuilder:

    var table = $('#example').DataTable({
            buttons: [
                {
                    extend: 'searchBuilder',
                }],
            dom: 'Bfrtip',
            searchBuilder: {    
                columns: [3,4,5],   // has no effect
                etc.
            },
    

    SearchBuilder was fully operational except for the Data drop-down list that listed all columns. (with dom: 'Qlfrtip' that also works, but is then not button-driven).
    I dug deeper in the examples and found this:

    var table = $('#example').DataTable({
            buttons: [
                {
                    extend: 'searchBuilder',
                    config: {
                        columns: [3,4,5]
                    }
                }]
            dom: 'Bfrtip',
    

    This works.
    The direct relationship between a button definition and the Data dropdown is unclear to me.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    The searchBuilder button type creates its own instance of SearchBuilder - you need to pass any configuration options you want for it to its config option.

    That and the searchBuilder options are really just short hand ways of saying new DataTable.SearchBuilder(table, options);.

    Allan

Sign In or Register to comment.