日期:2014-05-16  浏览次数:20384 次

谁有EasyUI treegrid具体实例 包含分页代码
谁有EasyUI treegrid具体实例 包含分页代码

------解决方案--------------------
treegrid.html
HTML code

<!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">
    <script type="text/javascript" src="../jquery-1.4.2.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_data.json',
                idField:'code',
                treeField:'code',
                pagination:true,
                frozenColumns:[[
                    {title:'code',field:'code',width:150}
                ]],
                columns:[[
                    {field:'name',title:'Name',width:120},
                    {field:'addr',title:'Address',width:120,rowspan:2},
                    {field:'col4',title:'Col41',width:150,rowspan:2}
                ]],
                onBeforeLoad:function(row,param){
                    if (row){
                        $(this).treegrid('options').url = 'treegrid_subdata.json';
                    } else {
                        $(this).treegrid('options').url = 'treegrid_data.json';
                    }
                }
            });
        });

        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