ztree吧 关注:1,830贴子:12,478
  • 2回复贴,共1

如何动态设置setting.check.chkStyle的值

取消只看楼主收藏回复

//配置信息
var setting = {
data: {
simpleData: {enable: true,idKey: "id",pIdKey: "pId",rootPId: 0}
},
check: {
enable: true,
chkStyle: "radio",
//chkStyle:function(){if($("#multiSelect").val() == "0"){return "radio";}else{return "checkbox";}},
radioType: "all"
}
};
-----------------------------------------------------------
setting.check.chkStyle是用来决定是单选还是多选的
我想在树加载前动态生成它的值(radio/checkbox),而不是像chkStyle: "radio"这样写死
就是根据URL&multiSelect=0中multiSelect的值是0还是1来决定树节点是单选还是多选
该怎么实现动态设置chkStyle的值?
我注释掉的那行代码是无效的......


IP属地:广西1楼2014-12-02 08:59回复
    不好意思,已经自己搞定了
    //初始化树
    function initTree()
    {
    multiSelect = $("#multiSelect").val();
    if(multiSelect=="1"){setting.check.chkStyle="checkbox";}
    $.fn.zTree.init($("#ztree"), setting,null);
    zTree = $.fn.zTree.getZTreeObj("ztree");
    }


    IP属地:广西2楼2014-12-02 09:38
    回复
      2025-08-16 06:23:26
      广告
      不感兴趣
      开通SVIP免广告
      async: {
      enable: true,
      type: "post",
      url: "/homepage.nsf/ajaxGetTreeNodesInfoForSelect?openAgent",
      dataType: "json",
      autoParam:["id=pId"]
      //,otherParam:{"curUserName":function(){return curUserName;}}
      }
      --------------------
      上面注释那行是可以的


      IP属地:广西4楼2014-12-02 09:52
      收起回复