qq_36010287
qq_36010287
采纳率0%
2016-09-01 01:04 阅读 1.1k

easyUI的datagrid无法从后台加载数据

 <script type="text/javascript">

        var setting = {
            data: {
                simpleData: {
                    enable: true,
                    idKey:"id",
                    pIdKey:"pid"
                }
            },
            callback: {
                    onClick: zTreeOnClick
                }

        };


    $(function(){
        $.ajax({
                url:"<%=request.getContextPath() %>/getDeptTree.action",
                data:{},
                dataType:"json",
                type:"post",
                success:function(json){
                    $.fn.zTree.init($("#treeDemo"), setting, json);
                }
            });
    });
        function zTreeOnClick(event, treeId, treeNode) {

            var id = treeNode.id;
            var deptName = treeNode.name;
            alert(id+","+deptName);

            $("#dl").datagrid({    
                url:"<%=request.getContextPath()%>/getUserByDeptid.action?id="+id,
               columns:[[
                    {field:'id',title:'ID',width:100},
                    {field:'realname',title:'真实姓名',width:100},
                    {field:'loginname',title:'用户名',width:100},
                    {field:'asd',title:'职位',width:100},
                    {field:'mail',title:'邮箱',width:100},
                    {field:'sex',title:'性别',width:100},
                    {field:'tel',title:'电话',width:100},
                    {field:'qq',title:'QQ',width:100},
                    {field:'adddate',title:'入职日期',width:100},
                    {field:'lastlogin',title:'最后登录时间',width:100},
                    {field:'logintime',title:'访问次数',width:100},
                    {field:'caozuo',title:'操作',width:100}
                ]],
                fit:true,
                singleSelect:true 
            });  
        };
    </script>
  <div id="zuzhi" class="easyui-tabs" data-options="fit:true,border:false">   
    <div title="用户" style="display:none;">   
        <div id="用户" class="easyui-layout" data-options="fit:true">   
            <div data-options="region:'west',title:'部门结构',collapsible:true" style="width:150px;">
                <ul id="treeDemo" class="ztree">

                </ul>
            </div>   
            <div data-options="region:'center'" style="padding:5px;background:#eee;">
                <table  id="dl">   
                   <!-- <thead>   
                        <tr>   
                            <th data-options="field:'id',width:100">ID</th>   
                            <th data-options="field:'realname',width:100,editor:'text'">真实姓名</th>   
                            <th data-options="field:'loginname',width:100,editor:'text'">用户名</th>   
                            <th data-options="field:'asd',width:100,editor:'text'">职位</th>   
                            <th data-options="field:'mail',width:100,editor:'text'">邮箱</th>   
                            <th data-options="field:'sex',width:100,editor:'text'">性别</th>   
                            <th data-options="field:'tel',width:100,editor:'text'">电话</th>   
                            <th data-options="field:'qq',width:100,editor:'text'">QQ</th>   
                            <th data-options="field:'adddate',width:100,editor:'text'">入职日期</th>   
                            <th data-options="field:'lastlogin',width:100,editor:'text'">最后登录时间</th>   
                            <th data-options="field:'logintime',width:100,editor:'text'">访问次数</th>   
                            <th data-options="field:'caozuo',width:100">操作</th>   
                    </thead>  -->
                </table>  
            </div>   
        </div>    
    </div>
    <div title="权限" data-options="" style="display:none;">   
        权限    
    </div>   

    <div title="公司" data-options="" style="display:none;">   
        公司   
    </div>   


    <div title="动态" data-options="" style="display:none;">   
        动态    
    </div>  
</div>

大牛帮看看什么原因

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • qq_36010287 qq_36010287 2016-09-01 01:08

    datagrid的getUserByDeptid.action都不进后台

    点赞 评论 复制链接分享
  • showbo GoCityPass新加坡曼谷通票 2016-09-01 01:18

    判断初始化过就直接调用reload方法,而不是又重新执行一次构造

     var init=false;
    function zTreeOnClick(event, treeId, treeNode) {
    
                var id = treeNode.id;
                var deptName = treeNode.name;
                alert(id+","+deptName);
    if(init) $("#dl").datagrid('reload',url:"<%=request.getContextPath()%>/getUserByDeptid.action?id="+id);
    else{
    init=true;
                $("#dl").datagrid({    ............................
    
    点赞 评论 复制链接分享
  • u012843100 lyzcren 2016-09-01 01:22

    这种情况下建议把url("<%=request.getContextPath()%>/getUserByDeptid.action?id="+id)打印出来看下url有没有错误

    点赞 评论 复制链接分享

相关推荐