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

    (@meitar)

    From the plugin FAQ:

    How do I change the default settings, like can I turn paging off? Can I change the page length? Can I change the sort order?

    If you’re able to add JavaScript to your theme, you can do all of these things, and more. Any and all DataTables-enhanced tables can be modified by using the DataTables API.

    For instance, to disable paging, add a JavaScript to your theme that looks like this:

    jQuery(window).load(function () {
        jQuery('#igsv-MY_TABLE_KEY').dataTable().api().page.len(-1).draw();
    });

    From this recent support thread:

    If you’re able to add JavaScript to your theme, you can do that. Any and all DataTables-enhanced tables can be modified by using the DataTables API.

    […]

    Please refer to the DataTables API reference manual for more information about customizing DataTables-enhanced tables.

    Hi!

    This trick work but it has some downsides.

    • The pagination button are still there at top and bottom
    • if set a pagination anyway, we can’t get back to the non pagniation mode

    To hide the residual pagination function, here is a bit of css:

    .dataTables_length, .dataTables_paginate, .paging_simple_numbers {display:none;}

    hope it can help !

    Plugin Author Meitar

    (@meitar)

    As of version 0.9 of this plugin, you can also use shortcode attributes like datatables_length_menu to affect this. For instance, to set the paging options to 5, 10, 25, and 50 instead of the default (10, 25, 50, 100), use a shortcode like this:

    [gdoc key="ABCDEFG" datatables_length_menu="%5B 5, 10, 25, 50 %5D"]

    This attribute sets the DataTables’s lengthMenu option. Other shortcode attributes affect other DataTable options, such as datatables_paging to turn the DataTables paging feature on or off, and datatables_page_length to set the DataTables pageLength option.

    X-Raym

    (@x-raym)

    Thanks for the update 🙂

    How would I add “All” to the example above?

    Plugin Author Meitar

    (@meitar)

    This example includes an “All” option in the length menu.

    The equivalent option in this plugin is the datatables_length_menu shortcode attribute.

    Cool, but how would this look? I tried

    datatables_length_menu=”%5B 25, 50, 100, “All” %5D”

    and it didn’t work

    Plugin Author Meitar

    (@meitar)

    Look more carefully at the example. The value of the lengthMenu option is a 2-dimensional array (arrays inside an array), what you typed out is just one array. 😉 Also, careful about your quotes: your attribute value in the shortcode should be single-quotes, not double-quoted, as per the FAQ:

    Note that when a JSON string literal is supplied in a shortcode attribute ("desc" [or in your case, "All"]), it must be double-quoted, so the shortcode attribute value itself must be single-quoted.

    Ok, so what do I need to type in the shortcode to get 25,50,100,200,All as the options?

    Plugin Author Meitar

    (@meitar)

    Ok, so what do I need to type in the shortcode to get 25,50,100,200,All as the options?

    Now you’re asking for a fish, not a question about how to fish.

    The fish you want is probably something like this:

    [gdoc key="ABCDEFG" datatables_length_menu='%5B%5B 10, 25, 50, -1 %5D, %5B 10, 25, 50, "All" %5D%5D ']

    Getting closer. Here is my current code and when you click on -1 it displays all, but it should say “All” in the dropdown. How do I fix?

    [gdoc key=”https://docs.google.com/spreadsheets/d/1″ datatables_page_length=”50″ query=”select A, B, C, D, E” use_cache=”no” datatables_length_menu=’%5B 10, 25, 50, -1 %5D’]

    Plugin Author Meitar

    (@meitar)

    All right, one last time. The lengthMenu defines two possible values: an array of lengths (numerically) or an array of two items, the first of which is the lengths, and the second of which is the labels. From the DataTables reference:

    This parameter allows you to readily specify the entries in the length drop down select list that DataTables shows when pagination is enabled. It can be either:

    • 1D array of integer values which will be used for both the displayed option and the value to use for the display length, or
    • 2D array which will use the first inner array as the page length values and the second inner array as the displayed options. This is useful for language strings such as ‘All’).

    Your shortcode value, %5B 10, 25, 50, -1 %5D, is one array, whose items are numbers, so you’re using the first type of value. To customize the page length display labels as well as the page lengths themselves, you need to use the second value (a “2D array which will use the first inner array as the page length values and the second inner array as the displayed options”). This is done like so, as I already showed above:

    %5B%5B 10, 25, 50, -1 %5D, %5B 10, 25, 50, "All" %5D%5D

    I hope this helps. If it’s not enough to help you out, then perhaps you should look into some JSON tutorials, the syntax used by these DataTables options. In the future, hopefully I’ll find time to enhance the GUI this plugin provides so people won’t have to touch the JSON directly, but that code hasn’t been written yet and, bluntly, I have more interesting things to do most of the time. 😉

    Patches and code contributions for enhancing this plugin submitted by others, of course, are always welcome.

    Thank you

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘pagination’ is closed to new replies.