How can I determine if a column is Searchable?

How can I determine if a column is Searchable?

alexcheveaualexcheveau Posts: 2Questions: 1Answers: 1

I'm using datatables.mark.js for highlighting the search in my datatables, but the plugin mark all columns including ones with searchable = false. I want to fix the plugin to mark only nodes inside columns with searchable = true.
Thanks in advance.

The code that mark the dt from the plugin:

            var globalSearch = this.instance.search();
            $(this.instance.table().body()).unmark(this.options);
            this.instance.columns({
                search: 'applied',
                page: 'current'
            }).nodes().each(function (nodes, colIndex) {
                var columnSearch = _this2.instance.column(colIndex).search(),
                    searchVal = columnSearch || globalSearch;
                if (searchVal) {
                    nodes.forEach(function (node) {
                        **$(node).mark**(searchVal,
                            // compatibilizar com a opção 'smart = false' do dataTable.Search
                            { "separateWordSearch": false });
                    });
                }
            });

This question has an accepted answers - jump to answer

Answers

  • alexcheveaualexcheveau Posts: 2Questions: 1Answers: 1
    Answer ✓

    Ok, i managed to fix it with this code:

                var _this2 = this;
                var globalSearch = this.instance.search();
                var _colIndex;
    
                $(this.instance.table().body()).unmark(this.options);
                this.instance.columns({
                    search: 'applied',
                    page: 'current'
                }).nodes().each(function (nodes, colIndex) {
                    var columnSearch = _this2.instance.column(colIndex).search(),
                        searchVal = columnSearch || globalSearch;
                    _colIndex = colIndex;
                    if (searchVal) {
                        nodes.forEach(function (node) {
                            if (_this2.instance.settings()[0].aoColumns[_colIndex].bSearchable) {
                                $(node).mark(searchVal,
                                    { "separateWordSearch": false });
                            }
                        });
                    }
                });
    
This discussion has been closed.