eazyui ajax传值,easyui datagrid怎么加载通过ajax获得的数据?

easyui datagrid如何加载通过ajax获得的数据??

从ajax中获得了数据,然后怎么把多个json对象让datagrid加载???

// 构建设备总览列表

$('#dg_machine_list').datagrid({

title : '设备列表模式',

iconCls : 'icon-a_detail',

fit : true,

fitColumns : true,

rownumbers : true,

pagination : true,

singleSelect : true,

border : false,

striped : true,

toolbar : [ {

text : '查看详情',

iconCls : 'icon-script_link',

handler : function() {

viewDetail();

}

}, '-', {

iconCls : 'icon-help',

handler : function() {

alert('帮助按钮');

}

} ],

columns : [ [ {

field : 'unid',

title : 'UNID',

width : 100,

align : 'center',

hidden : true

}, {

field : 'machine_name',

title : '设备名称',

width : 100,

align : 'center'

}, {

field : 'machine_type',

title : '设备类型',

width : 100,

align : 'center'

}, {

field : 'num_recoder',

title : '备案编号',

width : 100,

align : 'center'

}, {

field : 'work_state',

title : '当前状态',

width : 100,

align : 'center'

}, {

field : 'update_time',

title : '更新时间',

width : 100,

align : 'center'

}, {

field : 'moment',

title : '力矩(KN.m)',

width : 70,

align : 'center'

}, {

field : 'load',

title : '载重(t)',

width : 50,

align : 'center'

}, {

field : 'height',

title : '高度(m)',

width : 50,

align : 'center'

}, {

field : 'range',

title : '幅度(m)',

width : 50,

align : 'center'

}, {

field : 'angle',

title : '角度(度)',

width : 50,

align : 'center'

}, {

field : 'wind_speed',

title : '风速(m/s)',

width : 50,

align : 'center'

}, {

field : 'dip_angle',

title : '倾角(度)',

width : 50,

align : 'center'

}, {

field : 'alarm_info',

title : '报警信息',

width : 100,

align : 'center'

} ] ]

});

// 先通过ajax获取数据,然后再传给datagrid

// https://bas.gimiscloud.com/api/crane/machinelist

// json/data_machine_list.json

$.ajax({

method : 'GET',

url : 'https://bas.gimiscloud.com/api/crane/machinelist',

async : false,

dataType : 'json',

beforeSend : function(jqXHR) {

jqXHR.setRequestHeader('Authorization', 'Bearer '

+ '3feee5b76d8e698f4e5e29c626eb9dc2');

},

success : function(data) {

for ( var machine in data) {

alert(data[machine].name);

var a = [ {

'unid' : data[machine].unid,

'machine_name' : data[machine].name,

'machine_type' : data[machine].type,

'num_recoder' : data[machine].unid,

'work_state' : data[machine].online,

'update_time' : data[machine].date,

'moment' : data[machine].torque,

'load' : data[machine].capa,

'height' : data[machine].hook_height,

'range' : data[machine].radius,

'angle' : data[machine].angle,

'wind_speed' : data[machine].wind_velocity,

'dip_angle' : data[machine].obliquity,

'alarm_info' : data[machine].content

} ];

$('#dg_machine_list').datagrid('loadData', a);

}

},

error : function() {

alert('error');

}

});

------解决思路----------------------

多看下API就好了。。

------解决思路----------------------

在后台拼接json

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值