Reputation: 243
Is it possible to hide filters from certain columns only with jQuery tablesorter? First three columns don't need a filter(they only make the table longer).
<table id="userTable" class="table-sorter table table-striped table-bordered">
<thead>
<tr>
<th>
<input type="checkbox" /></th>
<th></th>
<th></th>
<th></th>
<th>Login
</th>
<th>Email
</th>
<th>Company
</th>
<th>LastName
</th>
<th>FirstName
</th>
<th>ZipCode
</th>
<th>City
</th>
<th class="filter-select" data-placeholder="Select">Country
</th>
</tr>
</thead>
Thx
Upvotes: 1
Views: 2005
Reputation: 86403
It looks like you're using my fork of tablesorter with the filter widget. So all you would need to do to disable a filter for a specific column is add the class name filter-false
to the th
:
<table id="userTable" class="table-sorter table table-striped table-bordered">
<thead>
<tr>
<th class="filter-false">
<input type="checkbox" /></th>
<th class="filter-false"></th>
<th class="filter-false"></th>
<th class="filter-false"></th>
<th>Login</th>
What that does is it still adds the filter to the filter row, but the input is disabled. Then all you would need to do is add this css:
/* hide disabled filter inputs */
.tablesorter-filter.disabled {
display: none;
}
Here is a demo of what I described above.
Upvotes: 0
Reputation: 5910
If you just want to hide them then you can do:
// Index starts at 0 so you want to hide elem 0, 1, 2 and 3
$('input:lt(4)').hide();
This hides the first for inputs. Example: http://jsfiddle.net/VWkJZ/
Upvotes: 0
Reputation: 243
I solved it by hiding the first four input fields.
// remove filters from first 4 columns
for (var i = 0; i < 4; i++) {
$('input[data-column='+i+']').hide();
}
Don't know if this is the right way.But it works. Grts Danny
Upvotes: 1
Reputation: 3330
I don't remember jQuery having a native tablesorter plugin, so I think your using this one: http://tablesorter.com/docs/
Which if you look down towards the config options. You will see 'headers' can be used to manually disable sorting on headers via passing options: { 0: { sorter: false}, 1: {sorter: false} }
which will disable sorting on the first 2 columns.
Just read that doc over and you should get it.
Upvotes: 3