转自:https://www.cnblogs.com/javaboy2018/p/8733585.html
代码:
按钮事件:
function formatOper(val, row, index) { var $row = JSON.stringify(row).replace(/\"/g,"'");//row的是一个对象 return '<a href="javascript:void(0)" class="editCabinet" onclick="editInfo('+$row+')"></a><a href="javascript:void(0)" class="delCabinet" onclick="deleteInfo('+$row+')"></a>'; };
接收:
//修改 function editInfo(row){ $('#addForm').form('load',{'infoGatewayIp.ip':row.ip,"infoGatewayIp.describe":row.ipDescribe, "infoGatewayIp.alarmValue":row.alarmValue,"infoGatewayIp.isMonitor":row.isMonitor, "infoGatewayIp.isEmail":row.isEmail,"infoGatewayIp.remark":row.remark,"id":row.id}); $('#titledialogs').dialog('open').dialog({ title:'修改网关配置', iconCls: 'icon-save', buttons: [ { text: '保存', iconCls:'icon-ok', handler: function(){ $.messager.confirm('系统提示', '您确定要修改吗?', function(r){ if (r) { var alarmValue = $("#alarmValue").val().trim(); if(alarmValue < 0 || alarmValue > 100 || !alarmValue.match(/[0-9]+/) || !/^\d+$/.test(alarmValue)){ $.messager.alert('系统提示', '报警值请输入0~100的整数', 'info'); return; } $("#searchIp").textbox('setValue',$("#addIp").val().trim()); $('#addForm').form('submit', { url: 'report/updateInfoGateway.action', onSubmit: function(){ var isValid = $(this).form('validate'); if (!isValid){ $.messager.progress('close'); } return isValid; }, success: function(data){ $.messager.progress('close'); $.messager.alert('系统提示', data, 'info'); if(data.indexOf('成功') >= 0){ $('#titledialogs').dialog('close'); var ip = $("#searchIp").val().trim(); if (ip.length == 0) { ip = ''; } loaddata(ip,1); } } }); } }); } }, { text: '取消', iconCls:'icon-cancel', handler: function(){ $('#titledialogs').dialog('close'); } } ] }); }