-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide Entire Column But Still Filter Table #477
Comments
Add a class to the columns. for every row-cell and header. you can use following to add the column class to filters after starting tablesorter -
for hiding a column, simply hide using the class $('.columnClass').hide(); if you have some other way of hiding column and you know the index of the column simply use the following - |
Hi @avoorhees! Actually, I have a new column selector widget (see issue #318) that uses css nth-child selectors instead of jQuery; but I haven't "officially" bumped the next version, but you can get the files by downloading the current repository zip file or copying them directly from here: example-widget-column-selector.html demo file & widget-columnSelector.js. |
Mottie himself! What a honor! I'm a little confused on how to use it. I don't want the column to be able to reappear rather just stay hidden but still sort based on its contents. Here is the code for the table that I have: (The 11th column still appears). I included
|
Hmm, ok... maybe you don't need that widget if the column is going to stay hidden. Try this instead (demo): HTML <button class="sort">Sort Hidden Column</button>
<button class="reset">Reset Filters</button>
<br>
<!-- use zero-based index of column in data-column -->
<input class="find" data-column="2" placeholder="Find in hidden column" type="search">
<br>
<table class="tablesorter">
...
</table> CSS /* which every column (one-based index) */
table th:nth-child(3),
table td:nth-child(3) {
display: none;
} Script $(function () {
var $table = $('table').tablesorter({
theme: 'blue',
widgets: ['zebra', 'filter'],
widgetOptions: {
filter_reset : '.reset'
}
});
$('.sort').on('click', function(){
$table.trigger('sorton', [ [[2,0]] ]);
});
$.tablesorter.filter.bindSearch( $table, $('.find') );
}); And I'm glad you feel honored, but I'm nobody famous ;P |
Worked like a charm. Much appreciated. Keep up the awesome work! |
Mottie, I'm trying to use the columnSelector widget to hide 2 columns in my table. I'm running the latest version (just updated everything). hey are extra data columns I just don't need to show. I an including the widget's js, added it to the widgets list in the config, and in my widgetOptions I have added columnSelector_columns : {
9 : false,
10 : false
} My columns still appear. Did I miss a step. Is there a better way to do this. I assume hiding columns is a basic feature, so I must just be missing something. |
Hi @pmolaro! I can only guess at the problem, but are the column indexes The <thead>
<tr>
<th>Student</th>
<th colspan="2">Info</th>
<th colspan="4">Courses</th>
</tr>
<tr>
<th>Name</th>
<th>Major</th>
<th>Sex</th>
<th>English</th>
<th>Japanese</th>
<th>Calculus</th>
<th>Geometry</th>
</tr>
</thead> and you want to hide the "Calculus" and "Geometry" columns, set the columns option as follows: columnSelector_columns : {
5 : false,
6 : false
} |
Hello i am using tablesorter with few more functionalities. I am using jquery ui sorting to sort the rows and updating the serial number on sorting now the issue came to me is when i click on some button i want to hide specific rows from tablesorter but if i do this with css display none it broke when i change the page all the rows are visible now also if i use css display none the rows on first pager should be 10 but after hiding 2 rows there are only 8 rows on 1st pager. Could you please help me how to hide the rows permanently and work on other rows i can give a hidden class to them |
Hi @yudicrownit! That is interesting. So you want to keep the column sort and still be able to manually sort rows? When hiding the selected rows, add a class name of |
Thanks for your reply @Mottie Well i did it...what i did is i just removed the inactive rows from the actual position to append to the last position in table with display:none!important and when use disable the toggle button inactive comes back to actual position...and for that bug where it was showing only 8 rows i am destroying the tablesorter and calling it again..now its working just perfect! |
Hi Mottie, I implemented the solution you gave to avoorhees. However my implementation is using a checkbox to display rows when the value 1 is in the hidden column or show all if empty. So the checkbox sets the value 1 in the hidden field and triggers the search (or clear the value in the hidden field and triggers the search). This works fine except that the search fields become visible on all fields. Is it possible to keep them hidden unless there is a search term entered as would be expected? |
Hi @pauldube! If you don't want to add a filter row, set the |
I like the filter row to hide when not necessary. Take a look at this demo. I want the filter row to disappear normally when checkbox is checked (if there is no text entered in any visible filters of course). |
Ah ok, I'll see what I can come up with to accomplish that request. |
Ok @pauldube! I've updated the You can use it as follows (demo) filter_hideFilters: function(config) {
// get an array of filter queries
var search = $.tablesorter.getFilters(config.$table);
// ignore any query is column 2 (zero-based index)
search.splice(2, 1);
// return true to hide the filter row, false to show it
return search.join("") === "";
} The demo is using the |
Ohhh! It works great. You're the best! |
First of all, love the plugin.
I have a use case where I want to hide the entire column (header,input,background of input, and row) but still need to be able to filter the table on this column. I use external buttons to filter instead of having the user type in input box.
The issue with this code is that the filter must be disabled, but I need the filter to still work, just the entire column hidden.
Thanks in advance!
The text was updated successfully, but these errors were encountered: