PicNet / tablefilter

This js project adds column filtering capabilities to a regular html <table> by adding a row to the <thead> section of a table and adding filters that allows real time filtering of tabular data.
http://web.archive.org/web/20150124160820/http://www.picnet.com.au/picnet-table-filter.html
27 stars 9 forks source link

How Do I autoselect values inside select fields? #35

Closed pepebe closed 12 years ago

pepebe commented 12 years ago

I'm sure this is an easy one, but I just can't see what I'm doing wrong here.

I have a table with n sortable columns (all of them select fields) plus 3 columns that are not sortable (one in the front column, two at the end).

For starters, I want to automatically pre-select the first item in select field #1 and filter the table by that value.

$('#filter_1 option:eq(1)').attr('selected','selected').trigger('change');

should do the trick from my point of view. Unfortunately this changes the select value, but it doesn't trigger the filter.

It would also be interesting to automatically preselect the first value in each of select field. but that's something I can solve as soon as I understand where I'm wrong in the first example.

Regards,

pepebe

BTW: Where can I find a readable version of this plugin. The non-minified one still uses incomprehensible variable names.

henrikl commented 12 years ago

Hi,

did you try the .tableFilterRefresh() function instead of the trigger('change')? TableFilter uses the closure library internally to set up the events, I'm guessing this is the reason why the jQuery trigger function doesn't trigger event handlers. Anyway try the .tableFilterRefresh() function and if that doesn't work write back here.

pepebe commented 12 years ago

Hi henriki,

.tablefilterRefresh() really hit the spot!

Thanks!

pepebe

Also thank you for the readable version of the .js file. :)

Edit: After closing this issue I noticed the "Closed issues tab". FOR THE FIRST TIME ever. And near the bottom I have found issues #5 and #15 that related to exactly the same Problem. I feel like an Id10T.

Thanks for your patience!