How to exclude columns for searchBuilder

How to exclude columns for searchBuilder

sloloslolo Posts: 65Questions: 12Answers: 1

Link to test case: https://live.datatables.net/faxuzaza/1/edit
Debugger code (debug.datatables.net): NA
Error messages shown: NA
Description of problem: Hello,

1./ Customizing SearchBuilder
I would like to know what is the way to include/exclude columns for SearchBuilder component like it is possible to do with "columnDefs" and orderable / searchable options?

You can have a look to the test case. I saw in documentation that we can "force" columns to be used by searchPanes but in my case, I would like to allow all columns by default and exclude them by configuration.

2./ SearchPanes behavior
Also, is it normal that in my really simple example serachPanes does not show anything?

3./ SearchPanes styling problem
And to finish, if you open searchBuilder pane you can see that it is contained into the red box (body)
If you open the searchPanes pane, you can see that it is shifted to the right (due to padding / margin of the body in the css)
Is it a small bug or not?

Thanks in advance for your answer and have a nice day.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,886Questions: 26Answers: 5,057

    Customizing SearchBuilder

    Use searchBuilder.columns. I uncommented "columns": [1, 2, 3] you have for the SearchBuilder config and it works. Maybe I'm not understanding the question.

    SearchPanes behavior

    Yes. SP uses a ratio of unique values to determine if the pane should be shown. Read about the details in the searchPanes.threshold docs. Yu can either adjust the ratio or use columns.searchPanes.show to display the pane.

    Updated test case:
    https://live.datatables.net/rigubavi/1/edit

    SearchPanes styling problem

    I'll let @allan comment on this. Probably needs adjustment to the applied CSS.

    Kevin

  • sloloslolo Posts: 65Questions: 12Answers: 1

    Hello @kthorngren,

    Use searchBuilder.columns. I uncommented "columns": [1, 2, 3] you have for the SearchBuilder config and it works. Maybe I'm not understanding the question.

    I commented out this line intentionally to show that I had read the documentation ;)

    As I said, I don't want to choose columns by inclusion but by exclusion (indeed, it's often simpler to exclude the last column than to have to list all the columns to include, especially across multiple tables that don't necessarily have the same number of columns).

    Yes. SP uses a ratio of unique values to determine if the pane should be shown. Read about the details in the searchPanes.threshold docs. Yu can either adjust the ratio or use columns.searchPanes.show to display the pane.

    Thanks for the tip, I haven't seen it :)

  • allanallan Posts: 64,266Questions: 1Answers: 10,609 Site admin
    Answer ✓

    If the columns have classes then you could use the :not() pseudo selector:

    searchBuilder: {
      columns: ':not(.unsearchable)'
    }
    

    Or I suppose for column indexes:

    searchBuilder: {
      columns: ':not(th:eq(1))'
    }
    

    Regarding the styling error - yup, something wrong there that I need to look into! Thanks for the test case.

    Allan

  • sloloslolo Posts: 65Questions: 12Answers: 1

    Hello @allan,

    Thansk a lot, it works very well with class selector :)

        searchBuilder: {
          columns: ':not(.unsearchable)'
        }
    

    Regarding the styling error - yup, something wrong there that I need to look into! Thanks for the test case.

    I have done another test case if you want to have a look.
    You will see the behavior of searchPanes (or searchBuilder) when it is on the right.

    https://live.datatables.net/qoyijezu/1/edit

    I hope you will be able to fix it in the next release :)

Sign In or Register to comment.