• Resolved kgagne

    (@kgagne)


    Hi,

    I’m using the filter extension to filter a table to show only Windows products, based on the product type being listed in the fourth column. Here is my shortcode;

    [table id=2 show_columns="1,2,3" hide_columns="4" alternating_row_colors=false print_description=false first_row_th=true filter="Windows" use_tablesorter=true /]

    Unfortunately, the use of hide_columns seems to be invalidating use_tablesorter. If I am hiding any column, the ones that are shown are not sortable; as soon as I remove the hide_columns parameter, tablesorting becomes enabled. The same holds true if I use the “aaSorting” custom command. Removing the filter command has no effect.

    I have “Yes, enable the use of a JavaScript library” enabled and set to DataTables, and “Yes, enable sorting of table data by the visitor.” enabled. I also checked my page’s source code and confirmed that the footer is loading /wp-content/plugins/wp-table-reloaded/js/jquery.datatables.min.js?ver=1.8.

    Any idea what could cause hiding a column to disable this feature?

    -Ken

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi Ken,

    can you provide the URL to the page with this Shortcode, where the sorting is not working?

    And out of curiosity: Why are you using the Shortcode parameters, if you have already set the checkboxes on the “Edit” screen? Or do you want to override those settings?

    Tobias

    Thread Starter kgagne

    (@kgagne)

    Tobias,

    Here’s the URL where I’m currently having trouble:

    http://www.gamebits.net/pc/

    I also tried switching the theme to the default “Twenty-Ten”.

    You’re right that I may be using some shortcode parameters that are redundant with the options I’ve already selected. I guess I did that in case the options in the admin interface ever change (intentionally or otherwise).

    What’s strange is that I have another site where I am using hide_columns and use_tablesorter together without issue. Here’s that example:

    http://www.apl2bits.net/2010/08/12/classic-gaming-inspirations-part-deux/

    And its shortcode:

    [table id=1 hide_rows="2,3,4,5,6,7,8,9,10" hide_columns="6" print_description=false first_row_th=true column_widths="29%|29%|14%|14%|14%" use_tablesorter=true /]

    Considering that I got it working in one place but not the other, I feel like I must be overlooking something obvious, and that I’ll be embarrassed when I realize the problem. :-\

    -Ken

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Ken,

    thanks for the link!

    I had a look at the source code and saw that you are using the “aoColumns” property in the DataTables “Custom Commands” textfield.
    In that property, you tell the library that you have four columns in the table, while in fact there are only three.
    So, if you remove the last “, null” from the “aoColumns” list, the sorting should work.

    Best wishes,
    Tobias

    Thread Starter kgagne

    (@kgagne)

    Tobias,

    I made that change and confirmed that tablesorting now works. Thanks! I appreciate you taking the time to look into my specific case.

    I am a bit confused why this worked, though. In the second example I gave above, on site apl2bits.net, only five columns are being displayed, even though six are defined:

    "aoColumns": [ null, null, { "sType": "html" },{ "sType": "html" },{ "sType": "html" },{ "sType": "html" } ]

    In that example, the sixth column is hid using hide_columns, as indicated in the shortcode — yet tablesorting still works. Why was there a conflict on Gamebits but not on Apple II Bits?

    -Ken

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Ken,

    very good question, but I don’t have an idea. Might be that it is important, what the “extra” item in the array is. Maybe it is ok if it is not “null”.

    I just thought that this might be a cause for the issue, as the DataTables documentation says that the number of elements in the “aoColumns” array *must* match the actual number of columns (see http://datatables.net/usage/columns)

    Best wishes,
    Tobias

    Thread Starter kgagne

    (@kgagne)

    Thanks, Tobias. In the Gamebits case, I was using aoColumns to define four columns that actually exist, but was displaying only three. I guess that’s why it didn’t occur to me to define three columns instead.

    Regardless, if this problem ever occurs again, I’ll know where to look!

    Thanks again.

    -Ken

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Ken,

    yeah, that’s probably the reason. Always keep in mind that the DataTables library (and with that the “aoColumns” array) don’t know about the “Edit” screen or its content. They basically only “see” what there really is on the page – which is the content after the Shortcode (with “hide_columns” and other parameters!) has been processed.

    Best wishes,
    Tobias

    Thread Starter kgagne

    (@kgagne)

    Tobias,

    In that case, I’m probably just lucky that the Apple II Bits table worked!

    BTW, I’m not sure which is better: your plugin, or its support. Both are fantastic.

    -Ken

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: WP-Table Reloaded] Hiding columns in sortable tables’ is closed to new replies.