方式一:如果需要参数可以在url中拼接,
- <table id="dg"></table>
- $('#dg').datagrid({
- url:'datagrid_data.json',
- columns:[[
- {field:'code',title:'Code',width:100},
- {field:'name',title:'Name',width:100},
- {field:'price',title:'Price',width:100,align:'right'}
- ]]
- });
方式二: 通过一些参数查询数据。
- $('#dg').datagrid('load', {
- name: 'easyui',
- address: 'ho'
- });
在向服务器改变数据之后,更新前台数据。
- $('#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":[
{},
{},
{}......
]}