How to set default value of Column-Toggle Table Widget for a column?

后端 未结 2 805
情深已故
情深已故 2021-01-15 03:35

I have been toying around with the Table Widget for jQuery Mobile. Is there a way I can set the show-hide status of a column from its table header name via this widget? If t

2条回答
  •  执念已碎
    2021-01-15 04:04

    jQM doesn't offer an out-of-the-box solution for this, therefore, you have to do it through JS. The column toggle popup inherits table's id followed by -popup. You need to target it when tablecreate event fires to change checkbox(es) property.

    Note that only thead elements with data-priority will be added to column toggle popup. Moreover, you will need to target checkbox(es) by their index using .eq() method or :eq() selector.

    $(document).on("pagebeforecreate", "#pageID", function () {
       $("#tableID").on("tablecreate", function () {
           $("#tableID-popup [type=checkbox]:eq(1)") /* second checkbox */
               .prop("checked", false)            /* uncheck it */
               .checkboxradio("refresh")          /* refresh UI */
               .trigger("change");                /* trigger change to update table */
       });
    });
    

    Demo

提交回复
热议问题