easyui中的$('#treedata').combotree()和 $('#pagegrid').datagrid()

**combotree**
<div class="layui-col-md3">
    <label class="layui-form-label">树形结构:</label>
    <div class="layui-input-block">
        <input id="treedata" type="text" name="title" required lay-verify="required"
       autocomplete="off" class="layui-input">
    </div>
</div>

<div data-options="region:'center',fit:true,border:false">
    <table id="pagegrid" data-options="region:'center',fit:true,border:false">
    </table>
</div>

$(’#treedata’).combotree()使用

//get请求 //请求路径 //{参数}
$.get('/api/···', {
   userId: id,
   roleLevel:roleLevel,
  },
     function (data) {
         //data就是所在板块的所有数据
         let list = [];
         list.push({
             id: "",
             isLeaf: false,
             name: "全部",
             parentId: "0",
             text: "全部",
             children: data.list
         });
         //异步请求
         $('#treedata').combotree({
             data: list,
             required: false,
             width: '100%',
             panelWidth: 300,
             onLoadSuccess: function () {
                 let tree = $('#treedata').combotree('tree');
                 tree.tree('collapseAll');
             },
             onClick: function (node) {
             }
         });
     });

$(’#pagegrid’).datagrid()使用 ,datagrid是个建表插件~用法

//查询参数 根据这些参数的选择对 $('#pagegrid').datagrid()表中的数据进行筛选显示
function getParams() {
        let params = {
            'roleLevel': roleLevel,
            'userId': userId,
            'manage': 2,
            'type': $.trim($("#type").val()),
            'title': $.trim($("#title").val()),
            'parentId': $.trim($("#treedata").val()),
            'create_time': $.trim($("#create_time").val()),
            'create_time_gt': $.trim($("#create_time_gt").val()),
            'create_time_lt': $.trim($("#create_time_lt").val()),
            'is_disabled': $.trim($("#is_disabled").val()),
            'status': $.trim($("#status").val()),
            'token': getToken(),
        };
        return params;
    }
 $('#pagegrid').datagrid({
            url:  '/public/···',//请求路径
            striped: true,
            pagination: true,//分页控件
            nowrap: false,
            pageSize: 10,
            pageList: [10, 20, 100],
            loader: trueLoader,
            queryParams: getParams(),//查询参数
            //固定属性列
            /*frozenColumns: [[

            ]],*/
            columns: [[
                {title: 'checkbox', field: 'checkbox', checkbox: true, halign: 'center', align: 'center', width: 120},
                {
                    title: '内容', field: 'title', halign: 'center', sortable: true, align: 'left', width: 300,
                    formatter: function (value, row, index) {
                        let e = "";
                        if (row.type == "content" && row.status == "1") {
                            e = "<div style='text-align: center'><b>" + '<a target="_blank" href="${request.contextPath}/' + row.id + '" style="color:blue;text-decoration:underline" >' + row.title + '</a> '
                                + "</b></div>";
                        } else if (!!row.title) {
                            e = "<div style='text-align: center'><b>" + row.title + "</b></div>";
                        } else {
                            e = "";
                        }
                        return e + row.content;
                    }
                },
                {
                    title: '类型',//表头
                    field: 'type',//需要的变量值
                    halign: 'center',
                    align: 'center',
                    width: 60,
                    formatter: function (value, row, index) {
                        if (row.type == "content") {
                            return "帖子";
                        } else if (row.type == "replay") {
                            return "回复";
                        } else if (row.type == "tip-off") {
                            return "举报";
                        }
                    }
                },
                {title: '创建时间', field: 'createDate', sortable: true, halign: 'center', align: 'center', width: 150},
                {
                    title: '操作',
                    field: '操作',
                    halign: 'center',
                    width: 100,
                    align: 'left',
                    formatter: function (value, row, index) {
                        let e = "";
                        if (row.type == "content") {
                            if (row.contenttype != 'txt_content') {
                                if (!!!row.topTime) {
                                    e = e + '<a href="#" style="color:red;text-decoration:underline" οnclick="zd(' + JSON.stringify(row).replace(/"/g, '\'') + ')">置顶</a> ';
                                } else {
                                    e = e + '<a href="#" style="color:red;text-decoration:underline" οnclick="unzd(' + JSON.stringify(row).replace(/"/g, '\'') + ')">取消</a> ';
                                }
                            }
                        }
                        if (row.isDisabled == "0") {
                            e = e + '<a href="#" style="color:red;text-decoration:underline" οnclick="jy(' + row.id + ')">禁用</a> ';
                        } else if (row.isDisabled == "1") {
                            e = e + '<a href="#" style="color:red;text-decoration:underline" οnclick="qy(' + row.id + ')">启用</a> ';
                        }
                        //e += '<a href="#" style="color:red;text-decoration:underline" οnclick="op(' + JSON.stringify(row).replace(/"/g, '\'') + ')">修改</a> ';
                        e += '<a href="#" style="color:red;text-decoration:underline" οnclick="op1(' + JSON.stringify(row).replace(/"/g, '\'') + ')">删除</a> ';
               return e;
                    }
                },
            ]],
            toolbar: '#toolbar',
            onLoadSuccess: onLoadSuccess,
            onLoadError: onLoadError, 
            loadFilter: loadFilter
        });
    });
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值