• Resolved lazarboy

    (@lazarboy)


    Hey, great plugin! Was looking for something like that. Thank you!

    I have a spreadsheet with almost 20 columns, and I’d like to have some of them displayed as child rows, collapsed by default and expandable if the user wishes to see more info.

    I’ve read about DataTables’ “responsive.details.renderer” and “Custom child row renderer”, but couldn’t figure out how to specify “show columns H, I, J & M as child rows” in IGSV’s shortcode, and couldn’t find it in the forum search either. Any help?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Meitar

    (@meitar)

    I’ve read about DataTables’ “responsive.details.renderer” and “Custom child row renderer”, but couldn’t figure out how to specify “show columns H, I, J & M as child rows” in IGSV’s shortcode, and couldn’t find it in the forum search either. Any help?

    That’s because this is not yet supported by the shortcode. Thank you for bringing this up. The documentation of this plugin contains a listing of all supported datatables_* shortcode attributes, and datatables_responsive is missing.

    It will take me some time to release a new version since I currently have very limited development resources to devote to this effort, but I have noted this request in the project’s issue tracker and will get around to it when I can (unless someone beats me to it and supplies a patch).

    In the mean time, you can consider using the DataTables Defaults Object setting in this plugin’s Settings screen, although this will apply your Responsive configuration to all DataTables-enhanced tables on your site. The shortcode would apply only to the one table to which the attribute is associated but, again, that integration is not implemented yet.

    Thread Starter lazarboy

    (@lazarboy)

    Hey Meitar, thanks for your answer.
    I tried the workaround – the result was completely deleting the existing defaults… probably because of bad syntax and formatting on my side, but perhaps a “restore defaults” option and a warning would help here.
    Anyway, I managed to restore the deaults by looking at the source code.

    I guess I didn’t really figure out what I should write in the defaults to make it work. Can you perhaps give a quick example of the default settings that would make columns G onwards to be shown as child rows automatically across all tables?

    Thanks.

    Thread Starter lazarboy

    (@lazarboy)

    (Or if there’s a simple JavaScript solution – also good ?? )

    Plugin Author Meitar

    (@meitar)

    if there’s a simple JavaScript solution – also good

    You can, of course, use the complete DataTables API that this plugin loads in your own scripts however you wish. At that point, though, you are working directly with the DataTables tooling, not this plugin, so refer to the DataTables reference manual and support forum, as noted in one of this forum’s sticky posts, for more information about how to work with DataTables. ??

    Thread Starter lazarboy

    (@lazarboy)

    Thanks Meitar, I was inspired by your replies and found a solution, in case anyone else is interested in something similar:

    Basically, you can use classes to customize the responsiveness of the table and force columns to appear no matter what (class “all”) while forcing other columns to always be displayed as child rows (class “none”).

    I added this simple search&replace filter to modify classes of specific columns (in this example, col 8 will be forced to be a child row, while col 9 will display normally no matter what):

    function modify_cols ($html) {
    $search = array("th class=col-8", "col-9 ");
    $replace = array("th class=col-8 none", "col-9 all ");
    
    return str_replace($search, $replace, $html);
    }
    add_filter('gdoc_table_html', 'modify_cols');

    More info and additional tweaking for different screen sizes can be found here.

    • This reply was modified 7 years, 5 months ago by lazarboy.
    • This reply was modified 7 years, 5 months ago by lazarboy.
    • This reply was modified 7 years, 5 months ago by lazarboy.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Controlling child rows by column’ is closed to new replies.