Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Filter widget and addRows #86

Closed
Raigen opened this Issue Jun 5, 2012 · 5 comments

Comments

Projects
None yet
2 participants

Raigen commented Jun 5, 2012

When I am using the new custom filter widget and add a row with the addRows-Event the filter widget no longer works. There is no error in the console it just stop working. If there is a filter on the table it will be resetted and the whole table is shown.

Raigen commented Jun 5, 2012

Sorry, my mistake. It is working fine.

@Raigen Raigen closed this Jun 5, 2012

@Raigen Raigen reopened this Jun 5, 2012

Raigen commented Jun 5, 2012

I should not create issues this early in the morning... or start to drink coffee maybe.

The filter widget is working fine with the addRows-event. But if I add a row that not fit the filter it will yet be shown in the table.
For example I filter a string-column for a starting B (with filter_startsWith: true). When I add a new row with the word Test in that column the filter will keep active but the row will be shown too.

Owner

Mottie commented Jun 5, 2012

LOL no worries, I don't drink coffee either.

This may not be the best solution, but I the quick-fix I made was to trigger the filter widget when it sees an "addRows" or "updateCell" event on the table. It works, even in IE7, but I'm afraid that if a lot of rows are added, the timing between adding the rows and the filter widget running may not coincide properly and not update the filter widget results properly. So in that event, the easiest solution would be to just trigger the filter widget yourself by triggering a search event on the input:

$('table')
    // add rows
    .find('tbody').append($rows)
    .trigger('addRows', [ $rows, true ])
    .end()
    // find any filter widget input (first one targeted here)
    .find('input.tablesorter-filter:first')
    // trigger a search
    .trigger('search');

I'll have the fix added to the next update.

Thanks for reporting this issue!

Raigen commented Jun 5, 2012

Thanks for the answer and solution. The problem is not so critical in my project so there is no need for a quick fix on my side.

My first thought was to listen for an addRows-event in the filter widget and hide those rows do not fit with the filter. But I do not know yet how the filter widget works so I don't know if this idea is practicable.

Owner

Mottie commented Jun 5, 2012

That is essentially what the fixed I've added will do. I'm just doing some other minor cleanup and I'll have the updates available.

@Mottie Mottie closed this Jun 10, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment