Forcing Display information to update?

Forcing Display information to update?

ChristinaChristina Posts: 4Questions: 0Answers: 0
edited July 2009 in General
I'm providing a series of checkbox controls in my table where users can show and hide columns and rows. I'm using fnSetColumnVis() to toggle my columns. For my rows, I'm giving them a specific className and using a basic jquery toggle:

[code]
$(".practice").click(function(){ //checkboxes
divName = $(this).attr("name"); //Name of checkbox corresponds to classname of table row
$("." + divName).toggle(); //Toggle the row
}
[/code]

This all works perfectly fine, except the display information ( showing 1-33 of 33 entries) doesn't know to update causing it be to inaccurate. Is there a function I can call to force the display information to update? Or is there a better way for me to implement this?

Thank you!
Christina

Replies

  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    HI Christina,

    DataTables doesn't allow for hiding rows by setting them to hidden via CSS (the reason being is that the DOM node still exists and it is inserted into the table by DataTables as required - so it thinks it is there. We could re-scan for the CSS display attribute on each draw, but that would lead to a horrendous performance drop).

    So what I think you need to do is use filtering (which is the mechanism DataTables uses to show/hide rows). What you could do is to have a hidden column the content of which changes depending on if it should be shown or not. Then using the filtering function (fnFilter) you can filter what you want.

    Another option which doesn't involve a hidden column is to use the custom filtering API to match on class names - but this is a bit more complicated. Depends on how you want to do it really :-)

    Regards,
    Allan
  • ChristinaChristina Posts: 4Questions: 0Answers: 0
    edited July 2009
    Hi Allan,

    I wish I wasn't such a newbie. Both solutions sound like more than I am capable of implementing. I'm going to try to talk my client out of needing this feature.

    Thank you again for making this excellent plugin available to "coding mortals" like myself. I just made a donation to you. My U.S. dollars won't go very far once converted to your British Pound, but hopefully it is enough for a few beers.

    Cheers!
    Christina
  • allanallan Posts: 63,578Questions: 1Answers: 10,483 Site admin
    Hi Christina,

    I'm sure you are quite capable of implementing it :-). If you have already implemented something t toggle the show/hide of a row, then it's not a great leap to using a hidden column and filtering. You just need to change the value of the cell and then draw the table again. If you do want to give it a go - post any questions in the forum.

    Regarding your donation - thanks very much! It is very much appreciated! Help pay for the bandwidth bills and a couple of beers ;-)

    Regards,
    Allan
This discussion has been closed.