首頁  >  文章  >  web前端  >  jquery easyui中treegrid用法的簡單實例

jquery easyui中treegrid用法的簡單實例

高洛峰
高洛峰原創
2016-12-29 15:05:111346瀏覽

專案需求如下圖,在服務端傳回的json資料中,要經過JS處理,新增複選框,且複選框需回應JS操作。

jquery easyui中treegrid用法的简单实例

在easyui 的treegrid中,沒有找到現成的插件,自己需要修改整理,代碼如下

<table class="easyui-treegrid" style="width:700px;height:250px"  url=&#39;control_node_json?group_id=$info[id]&access_node=$_REQUEST[access_node]"&#39; idField="id" treeField="title" fit="true" toolbar="#control_node_toolbar_{$info[id]}">
        <thead>  
          <tr>
            <th field="title" width="200px" data-options="formatter:title_formatter">名称</th>
            <th field="name" width="200px">节点</th>
            <th field="status" width="50px">状态</th>
            <th field="remark">备注</th>
          </tr>
          <thead>  
        </table>
        <div id="control_node_toolbar_{$info[id]}">
            <a href="javascript:alert(&#39;test&#39;);" class="easyui-linkbutton" iconCls="icon-add" plain="true">控制</a>
        </div>

上面是整個HTML代碼,其中在easyui的好處是,JS調用的各種屬性都可以直接寫在table的屬性裡,直覺易懂。接下來就把checkbox加進去。

//对名称列数据进行格式华
var access_node=&#39;{$_REQUEST[access_node]}&#39;.split(&#39;,&#39;);
function title_formatter(value,node){ 
 var content=&#39;<input name="set_power" id="set_power_&#39;+node.id+&#39;" onclick="set_power_status(&#39;+node.id+&#39;)" class="set_power_status" type="checkbox" value="&#39;+node.id+&#39;" />&#39;+value;
 return content;
}
function set_power_status(menu_id){
 alert(&#39;要调用的函数和操作方法写这里&#39;);
}

其中用checkbox用$(set_power_1")這種方法是響應不了的,估計是因為easyui經過處理的原因。

更多jquery easyui中treegrid用法的簡單實例相關文章請關注PHPtreegrid !

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn