//设置treegrid自适应
$(window).resize(function(){
$('#treeGrid').treegrid('resize', {
width: '100%'
})
});
//js获取项目根路径,如: http://localhost:8088/jquery
function getRootPath(){
//获取当前网址,如: http://localhost:8088/jquery/easyui/login.jsp
var curWwwPath = window.document.location.href;
//获取主机地址之后的目录,如: jquery/easyui/login.jsp
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
//获取主机地址,如: http://localhost:8088
var localhostPaht = curWwwPath.substring(0, pos);
//获取带"/"的项目名,如:/jquery
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
return (localhostPaht + projectName);
}
var treeGrid;
$(function(){
InitTreeGrid();
});
/**
* 初始化treegrid
*/
function InitTreeGrid(){
treeGrid = $('#treeGrid').treegrid({
url: getRootPath() + '/treeGrid',
title: '编辑treeGrid',
rownumbers: true,
idField: 'id',
treeField: 'text',
width: '100%',
fitColumns: true,
columns: [[{
title: '序号',
field: 'id',
align: 'center',
//复选框
checkbox: true
}, {
title: '名称',
field: 'text',
width: 280
}, {
title: '全名',
field: 'fullname',
width: 280,
align: 'right'
}, {
title: '英文名',
field: 'nameen',
width: 280
}, {
title: '级别',
field: 'level',
width: 280
}, {
title: '状态',
field: 'status',
width: 280
}]],
toolbar: [{
id: 'idAdd',
text: '增加',
iconCls: 'icon-add',
plain: 'true',
//按钮事件
handler: function(){
}
}, '-', {
id: 'idDelete',
text: '删除',
//disabled: true,
iconCls: 'icon-remove',
//按钮事件
handler: function(){
}
分享到:
相关推荐
在TreeGrid中添加复选框(checkbox)可以方便用户进行多项选择,比如批量删除、选中等操作。 实现TreeGrid上显示checkbox并取选定值的基本思路是利用formatter自定义渲染单元格,在特定的列中插入checkbox,并在...
首先,要实现 Treegrid 中的复选框功能,我们需要在列定义(columns)中增加一个字段,该字段将用于显示复选框。例如,我们可以创建一个名为 `IsChecked` 的隐藏字段,用于存储每个节点的选中状态。在初始化 ...
在 `title_formatter` 函数中,我们实现了为每一行的 `title` 列添加一个复选框。这里使用了 `access_node` 变量,将其值分割成数组,然后在创建复选框时设置其值。`set_power_status` 函数则是当用户点击复选框时...
easyUI 创建Tree和复选框Tree Node easyUI 拖动(Drag)和放置(Drop)Tree easyUI 加载parent/child节点到tree 转换tree标准格式数据 easyUI 创建一个基础的TreeGrid easyUI 创建复杂TreeGrid Form easyUI ...
有许多开源的JavaScript库,如jQuery UI、EasyUI、zTree等,都提供了TreeGrid功能,并且可以方便地添加复选框。以jQuery UI为例,它的TreeGrid可以通过插件实现,而zTree则内置了复选框支持。 在实现这一功能时,...
| checkbox | boolean | 是否包含复选框 | 否 | false | **2.3. Operate(操作)子标签** - **2.3.1. 删除操作标签** ``` 删除" iconCls="icon-remove" confirmMsg="确定要删除吗?" operation="delete"> ``` ...