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
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