treegrid复选框



然后是代码:
html文件:
<body>
       <h1>TreeGrid</h1>
       <div>
              <a id="consle" href="#">consle</a>
       </div>
       <table id="test" title="Folder Browser" style="width:400px;height:300px" >            
       </table>     
</body>
说明:没什么内容,标题,然后是一个表格,我为了做些测试放了个按钮consle,不用删掉即可,当然要引用几个js文件和css文件:
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <meta name="keywords" content="jquery,ui,easy,easyui,web">
       <meta name="description" content="easyui help you build your web page easily!">
       <title>jQuery EasyUI Demo</title>
       <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
       <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
       <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
       <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
       <script type="text/javascript" src="ws.js"></script>


接着是js文件:
$(function(){
       $('#test').treegrid({ 
              url:"data/treegrid_data.json", 
              idField:'id', 
              treeField:'name', 
              animate:"true",
              rownumbers:"true",
              columns:[[ 
                     {title:'Task Name',field:'name',formatter :function(value,rowData,rowIndex){
                            return "<input type='checkbox'>"  + rowData.name;
               },width :180}, 
                     {field:'size',title:'Persons',width:60,align:'right'}, 
                     {field:'date',title:'Begin Date',width:80}
              ]] 
       });
       $("#consle").bind("click",consleclick)
});

function set_power_status(){ 
       var idList = ""; 
         $("input:checked").each(function(){
               var id = $(this).attr("id");
               if(id.indexOf("ceshi_")>-1)
                       idList += id.replace("ceshi_",'')+',';
         })
       alert(idList);
}

function consleclick(){
       var node = $('#test').treegrid('expandAll',2);
}

说明:调用了easyUI的treegrid,为了显示checkbox,对第一列做了个formatter,为了展示效果绑定了取得选中checkbox的事件,不用可以去掉,也可以去掉alert,更改为其他的事件处理函数。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值