jquery easyui treegrid demo

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery EasyUI</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
<script>
$(function(){
$('#test').treegrid({
title:'TreeGrid',
iconCls:'icon-save',
width:500,
height:350,
nowrap: false,
rownumbers: true,
animate:true,
collapsible:true,
url:'../treegrid/demo.json',
idField:'code',
treeField:'code',
pagination:true,
frozenColumns:[[
                {title:'code',field:'code',width:150}
]],
columns:[[
{field:'name',title:'Name',width:120},
{field:'size',title:'Size',width:120,rowspan:2},
{field:'date',title:'date',width:150,rowspan:2}
]]
});
});

function reload(){
$('#test').treegrid('reload');
}
function getChildren(){
var node = $('#test').treegrid('getSelected');
if (node){
var nodes = $('#test').treegrid('getChildren', node.code);
} else {
var nodes = $('#test').treegrid('getChildren');
}
var s = '';
for(var i=0; i<nodes.length; i++){
s += nodes[i].code + ',';
}
alert(s);
}
function getSelected(){
var node = $('#test').treegrid('getSelected');
if (node){
alert(node.code+":"+node.name);
}
}
function collapse(){
var node = $('#test').treegrid('getSelected');
if (node){
$('#test').treegrid('collapse', node.code);
}
}
function expand(){
var node = $('#test').treegrid('getSelected');
if (node){
$('#test').treegrid('expand', node.code);
}
}
function collapseAll(){
$('#test').treegrid('collapseAll');
}
function expandAll(){
$('#test').treegrid('expandAll');
}
function expandTo(){
$('#test').treegrid('expandTo', '02013');
$('#test').treegrid('select', '02013');
}
</script>
</head>
<body>
<h1>TreeGrid</h1>
<div style="margin:10px;">
<a href="#" onclick="reload()">reload</a>
<a href="#" onclick="getChildren()">getChildren</a>
<a href="#" onclick="getSelected()">getSelected</a>
<a href="#" onclick="collapse()">collapse</a>
<a href="#" onclick="expand()">expand</a>
<a href="#" onclick="collapseAll()">collapseAll</a>
<a href="#" onclick="expandAll()">expandAll</a>
<a href="#" onclick="expandTo()">expandTo</a>
</div>
<table id="test"></table>

</body>
</html>





<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Treegrid分页 - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="themes/metro/easyui.css">
<link rel="stylesheet" type="text/css" href="themes/icon.css">
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="jquery.easyui.min.js"></script>
<script>
$(function(){
$("#tt").treegrid({
url: 'treegrid-data.php',
idField: 'areaid',
treeField: 'name',
rownumbers: true,
pagination: true,
fitColumns: true,
autoRowHeight: false,
onLoadSuccess: function() {
delete $(this).treegrid('options').queryParams['id'];
}
});
});
</script>
</head>
<body>
<h1>Treegrid分页演示</h1>
<p>Treegrid分页的分页其实就是tree的顶级节点分页,下面的子节点其实是不分页的...</p>
<table id="tt" title="Treegrid分页" style="width:550px;height:300px">
      <thead>
        <tr>
          <th data-options="field:'name'" width="200">
            名称
          </th>
          <th data-options="field:'vieworder'" width="200">
            排序
          </th>
        </tr>
      </thead>
    </table>
</body>
</html>

你可能感兴趣的:(jquery)