• Resolved TedAvery

    (@tedavery)


    I have the Tablepress Responsive extension, and I am trying to set the responsive.details.display option of Datatables to childRowImmediate so that the collapsed row details will be immediately expanded on mobile, as per this example. However, Tablepress automatically overrides the responsive options on initialisation, so they cannot be customised with custom commands.

    For example, my table has this custom command set:

    responsive: {
            details: {
                display: $.fn.dataTable.Responsive.display.childRowImmediate,
                type: ''
            }
        }

    Using this shortcode: [table id=1 responsive=collapse /]

    Results in this initialisation:

    $('#tablepress-1').dataTable({"stripeClasses":["even","odd"],"ordering":false,"paging":false,"searching":false,"info":false,responsive: {
            details: {
                display: $.fn.dataTable.Responsive.display.childRowImmediate,
                type: ''
            }
        },"responsive":true});

    Note that there are 2 responsive properties, the 2nd being added automatically and taking priority over the first.

    I’ve tried removing the responsive property from the shortcode ([table id=1 /]) but then the responsive JS extension for Datatables doesn’t load on the page at all, so my options don’t do anything.

    Thanks for all your work on this great plugin!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    The “trick” here is to write this as properly escaped JSON code, i.e. quote the strings with quotation marks:

    "responsive": {
            "details": {
                "display": $.fn.dataTable.Responsive.display.childRowImmediate,
                "type": ""
            }
        }

    Can you please try that?

    Regards,
    Tobias

    Thread Starter TedAvery

    (@tedavery)

    D’oh… that did it! Thanks a lot for the quick help and great plugin! ?? I’ve dropped a tip in your Paypal tip jar!

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    And thanks for the donation, I really appreciate it!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cannot set Datatables options for Responsive extension’ is closed to new replies.