Disable SearchBuilder for Column

Disable SearchBuilder for Column

washuit-iammwashuit-iamm Posts: 133Questions: 55Answers: 2
  {
    title: "Product Tags",
    data: "Product",
    render: function (products) {
      return products.reduce(function (acc, cur) {
        return acc + `<span class="badge text-bg-light mx-1">${cur.Name}</span>`;
      }, "");
    },
    visible: true,
    sortable: false,
    searchable: false, // This does not disable searchBuilder!!!
  },

Looking for something like searchBuilderEnabled: false

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    Answer ✓

    See if searchBuilder.columns does what you want.

    Kevin

  • washuit-iammwashuit-iamm Posts: 133Questions: 55Answers: 2

    @kthorngren

    That is a white-list and not a black-list right?

    I have over 100 columns, that would be very ugly for me to have to remember yet another place to list my columns.

    If it automatically opts-in to my columns, why cant I opt-out?

  • washuit-iammwashuit-iamm Posts: 133Questions: 55Answers: 2

    @kthorngren

    Went with this route, don't love it but its terse enough...

    columns: function (idx, data, node) {
        const column = table.column(idx);
    
        if (column.title().toLowerCase() ===
            "product tags") {
                return false;
        }
    
        return true;
    }
    
  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    Answer ✓

    The searchBuilder.columns states this:

    This accepts all of the options of column-selector such as class name selector, jQuery pseudo selects and column index selectors.

    You could assign a className to the columns you want to opt-out of SearchBuilder then use the jQuery :not() selector. For example:
    https://live.datatables.net/fabaxeni/1/edit

    Kevin

Sign In or Register to comment.