Skip to content
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

Error with empty table and pager widget #450

Closed
Prestaplugins opened this issue Dec 3, 2013 · 6 comments
Closed

Error with empty table and pager widget #450

Prestaplugins opened this issue Dec 3, 2013 · 6 comments
Labels

Comments

@Prestaplugins
Copy link

Hello,

Sorry if the following bug has already been reported...

I'm trying to create a table with tablesorter, pager and filter widget.
My table needs to be empty at start, then I add rows with javascript.

I made a simple test following the examples.
Example 1 : http://www.prestaplugins.com/test/tablesorter/example1.html

If you click "Add row", you can see an error is thrown :
TypeError: c.cache[tbdy] is undefined

It's the same if you create a table witch is not empty at start, then you remove all rows by clicking "Remove row" and then you try to add a new one.
Example 2 : http://www.prestaplugins.com/test/tablesorter/example2.html

So I tried something. When I create a row, if it's the first one, I restore the pager widget AFTER the first line is added.
And if I remove the last row, I destroy the pager widget.
It seems working... but there's a new issue.
If my page default size is 10 rows, then after removing all, if I add a lot, the 12th appears on the first page with all the next ones until 20, so there is more than 10 rows in my page. Then at 30th row, all rows from 12 to 30 disappears but those from 20 to 30 are displayed...
Example 3 : remove the line, then click on Add many times (more than 12).
http://www.prestaplugins.com/test/tablesorter/example3.html

I worked on this all the day trying to find a solution, I'm so tired...
You're my last hope, please HELP...

Last thing... I don't understand why the filter doesn't appears even when my table is not empty at start, like in example 2. But I didn't investigate on this...

@Mottie
Copy link
Owner

Mottie commented Dec 3, 2013

Hi @Patanock!

That looks like it's a bug in the addRows method... it expects the cache to not be empty. I'll have this issue fixed in the next update; but until then I would suggest using the update method (updated demo)

function addLine() {
    i++;
    line = $('<tr><td>'+i+'</td><td>'+i+'</td></tr>');
    $('.tablesorter tbody').append(line).trigger("update");
}

And just using "update" should take care of all 3 problems that you've described.

Edit: Oh, and the filter row is made to hide when there is no content to filter.

@Prestaplugins
Copy link
Author

Hi @Mottie !

OMG Thanks !! It seems to work, but I can't believe that I didn't test it. I thought I tried all the combinations.
So much time lost... :(

About the filter, why doesn't it appear on example2 ? There's content.
Or how to make it appears at start even if the table is empty, or at least after the first row is added ?

@Mottie
Copy link
Owner

Mottie commented Dec 4, 2013

Example 2 isn't working because of the addRows bug... try adding rows in the demo I shared above... hmm, but I guess it doesn't hide the filter row if you delete all the rows after adding some. I'll fix that too.

@Mottie Mottie closed this as completed in 328bba3 Dec 14, 2013
@Mottie
Copy link
Owner

Mottie commented Dec 14, 2013

Oops, forgot to fix the filter row hiding... ugh

@Mottie Mottie reopened this Dec 14, 2013
@Prestaplugins
Copy link
Author

Hi @Mottie !

I tried your demo at : http://jsfiddle.net/Mottie/abkNM/1675/
Everything seems ok except that the Zebra widget doesn't work on new lines.
Is that normal ?

I need to add this, after update to make it work :
$('.tablesorter').trigger('refreshWidgets', true, false);

@Mottie
Copy link
Owner

Mottie commented Jan 8, 2014

Hi @Patanock!

Yeah, sorry. With the holidays and going out of town I haven't had a chance to finish updates and push out the next version. Once that is done, there is already a fix in place that will solve that issue (without needing to trigger refreshWidgets). Sorry for the inconvenience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants