如何为列设置Column-Toggle Table Widget的默认值? [英] How to set default value of Column-Toggle Table Widget for a column?

查看:127
本文介绍了如何为列设置Column-Toggle Table Widget的默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩jQuery Mobile的Table Widget。有没有办法可以通过这个小部件从其表头名称设置列的显示隐藏状态?如果没有这样的方法什么是这个问题的最佳解决方案?

解决方案

jQM不提供开箱即用的解决方案,因此,你必须通过JS来做到这一点。 列切换弹出窗口继承 id ,然后是 -popup 。当 tablecreate 事件触发以更改复选框属性时,您需要定位它。



<请注意,只有 thead 元素数据优先级才会添加到列切换弹出。此外,您需要使用 .eq()方法或<$,通过 index 定位复选框 c $ c>:eq() selector。

  $(document).on(pagebeforecreate ,#pageID,function(){
$(#tableID)。on(tablecreate,function(){
$(#tableID-popup [type = checkbox]: eq(1))/ *第二个复选框* /
.prop(checked,false)/ *取消选中* /
.checkboxradio(refresh)/ *刷新UI * /
.trigger(change); / *触发更改为更新表* /
});
});




演示



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 there is no such way what will be the best solution for such a problem?

解决方案

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

这篇关于如何为列设置Column-Toggle Table Widget的默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆