How to exclude column in column filtering
How to exclude column in column filtering
NoBullMan
Posts: 104Questions: 31Answers: 3
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
I am using column filtering using this example.
The first column in my table is a "select" column, with checkoxes. I am trying to exclude it from filtering.
I can stop the input textbox from displaying by checking if column index is zero or not:
(although not sure if this is the right way of doing it or not.)
initComplete: function () {
var api = this.api();
var cursorPosition;
// For each column
api
.columns()
.eq(0)
.each(function (colIdx) {
if (colIdx != 0) {
...
}
});
However, I am not sure how to prevent the first column to be cloned in:
$('#MyTable thead tr')
.clone(true)
.addClass('filters')
.appendTo('#MyTable thead');
Answers
The
columns()API as many options for selecting the columns. See thecolumn-selector. You might be able to use:not(:first-child)to skip the first column, for example:Kevin
Thank you Kevin. It is the cloning part I am struggling with.
Ah. So you want the first column to span both header rows? After cloning you will need to remove the
thin the second row and set therowspanattribute to 2 for the firstthin the first row. Like this:http://live.datatables.net/muqijeya/1/edit
Kevin
Thank you; that did it. I had to revert back the initial change from
to
Weirdest thing happens now!
When I type something in column X's input box, it searches column X-1.
I think first-child of the columns has moved one to the right.
Had to also change:
to