easyui加载数据

方式一:如果需要参数可以在url中拼接,

 
  1. <table id="dg"></table>
 
  1. $('#dg').datagrid({
  2. url:'datagrid_data.json',
  3. columns:[[
  4. {field:'code',title:'Code',width:100},
  5. {field:'name',title:'Name',width:100},
  6. {field:'price',title:'Price',width:100,align:'right'}
  7. ]]
  8. });

方式二: 通过一些参数查询数据。

 
  1. $('#dg').datagrid('load', {
  2. name: 'easyui',
  3. address: 'ho'
  4. });

在向服务器改变数据之后,更新前台数据。

 
  1. $('#dg').datagrid('reload'); // reload the current page data

方式三:使用ajax请求数据之后,再进行封装数据,有的时候返回的数据需要再做处理

    

$.ajax({
    url: "${rc.contextPath}/borrower/weeklyByStageFa",
    dataType: 'json',
    type: 'post',
    data: {
        uid:${uid}
    },
    cache: false,
    success: function (da) {
        var arr1 = [];
        var arr2 = [];
        var arr3 = [];
        for (var i = 0; i < da.length; i++) {
            var json = eval('(' + da[i] + ')');
            if (json.dataType == "zxgg") {
                arr1.push(json);
            } else if (json.dataType == "sxgg") {
                arr2.push(json);
            } else if (json.dataType == "cpws") {
                arr3.push(json);
        }
        $('#table_List2').datagrid({
            fit: true,
            columns: [[{field: 'zxggId', width: '100', title: '执行公告id', checkbox: true, hidden: true},
                {field: 'body', title: '内容', width: '100', sortable: false,},
                {field: 'title', title: '标题', width: '100', sortable: false,},
                {field: 'pname', title: '执行人姓名', width: '100', sortable: false,},
                {field: 'court', title: '执行法院名称', width: '100', sortable: false,},
                {field: 'dataType', title: '数据类型', width: '100', sortable: false,},
                {field: 'sortTimeString', title: '立案时间', width: '100', sortable: false,},
                {field: 'caseNo', title: '案号', width: '100', sortable: false,},
                {field: 'idcardNo', title: '身份证号/组织机构代码', width: '100', sortable: false,},
                {field: 'caseState', title: '案件状态(0:执行中,1:已结案)', width: '100', sortable: false,},
                {field: 'execMoney', title: '执行标的', width: '100', sortable: false,},
                {field: 'cym', title: '查询企业曾用名', width: '100', sortable: false,},
                {field: 'keyId', title: '查看详情接口所需id', width: '100', sortable: false, hidden: true},
                {
                    field: 'descee', title: '查看详情', width: "100", height: "80", sortable: false,
                    formatter: function (value, row, index) {
                        var result = "";
                        result += "<a style='text-decoration:none;color:black;' href=\"javascript:;\"  οnclick='fahaiDetail(\"" + row.keyId + "\",\"" + $("#uid").val() + "\",0);'>查看详情</a>";
                        return result;
                    }
                }

            ]],
        });
        $('#table_List2').datagrid('loadData', arr1);
    
$('#tableList3').datagrid({
    fit: true,
    columns: [[{field: 'sxggId', width: '100', title: '失信公告唯一ID', checkbox: true, hidden: true},
        {field: 'court', title: '执行法院名称', width: '100', sortable: false,},
        {field: 'pname', title: '被执行人姓名', width: '100', sortable: false,},
        {field: 'body', title: '内容', width: '100', sortable: false,},
        {field: 'sortTimeString', title: '立案时间', width: '100', sortable: false,},
        {field: 'sex', title: '性别', width: '100', sortable: false,},
        {field: 'lxqk', title: '履行情况', width: '100', sortable: false,},
        {field: 'yjCode', title: '依据文号', width: '100', sortable: false,},
        {field: 'idcardNo', title: '身份证号/组织机构代码', width: '100', sortable: false,},
        {field: 'caseNo', title: '案号', width: '100', sortable: false,},
        {field: 'postTime', title: '发布时间', width: '100', sortable: false,},
        {field: 'cym', title: '查询企业曾用名', width: '100', sortable: false,},
        {field: 'keyId', title: '查看详情接口所需id', width: '100', sortable: false, hidden: true},
        {
            field: 'descee', title: '查看详情', width: "100", height: "80", sortable: false,
            formatter: function (value, row, index) {
                var result = "";
                result += "<a style='text-decoration:none;color:black;' href=\"javascript:;\"  οnclick='fahaiDetail(\"" + row.keyId + "\",\"" + $("#uid").val() + "\",2);'>查看详情</a>";
                return result;
            }
        }
    ]],
});
$('#tableList3').datagrid('loadData', arr2);

第二,三种方式加载数据都是请求数据之后返回后再加载本地数据的,根据不同需求使用.第一种方式需要注意的是后台返回的数据格式必须要

符合easyui指定格式(返回List<对象>就行)

            {"total":,"rows":[

                {},

                {},

                {}......

            ]}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值