datagrid 同时绑定多个事件

提问 未结 1 128
悬赏:20飞吻
datagrid 绑定多个事件现在的写法是如下:
现在想问的是,都执行同一种方法,是不是有更简单的写法?

data-options="id:'userDg',
rownumbers: true,
singleSelect:false,
url:_ctx+'ashx/Json_View_SJ_fontuser.aspx',
onCheck:function(index,row){
//1. 获取用户选中的所有值
var rows = $('#userDg').iDatagrid('getChecked');

//2. 遍历rows
var val = '';
var uid='';
$.each(rows,function(index){
val += rows[index].turename;
val = rows.length == (index+1) ? val: val+',';
uid += rows[index].uuid;
uid = rows.length == (index+1) ? uid: uid+',';
});

//3. 给用户输入框赋值
$('#m_truename').val(val);
$('#m_userid').val(uid);
},onCheckAll:function(index,row){
//1. 获取用户选中的所有值
var rows = $('#userDg').iDatagrid('getChecked');

//2. 遍历rows
var val = '';
var uid='';
$.each(rows,function(index){
val += rows[index].turename;
val = rows.length == (index+1) ? val: val+',';
uid += rows[index].uuid;
uid = rows.length == (index+1) ? uid: uid+',';
});

//3. 给用户输入框赋值
$('#m_truename').val(val);
$('#m_userid').val(uid);
},onUncheckAll:function(index,row){
//1. 获取用户选中的所有值
var rows = $('#userDg').iDatagrid('getChecked');

//2. 遍历rows
var val = '';
var uid='';
$.each(rows,function(index){
val += rows[index].turename;
val = rows.length == (index+1) ? val: val+',';
uid += rows[index].uuid;
uid = rows.length == (index+1) ? uid: uid+',';
});

//3. 给用户输入框赋值
$('#m_truename').val(val);
$('#m_userid').val(uid);
},onUncheck:function(index,row){
//1. 获取用户选中的所有值
var rows = $('#userDg').iDatagrid('getChecked');

//2. 遍历rows
var val = '';
var uid='';
$.each(rows,function(index){
val += rows[index].turename;
val = rows.length == (index+1) ? val: val+',';
uid += rows[index].uuid;
uid = rows.length == (index+1) ? uid: uid+',';
});

//3. 给用户输入框赋值
$('#m_truename').val(val);
$('#m_userid').val(uid);
}
"
回帖
回帖须知
QQ在线咨询
客服 QQ
251122361
微信/手机
18973127736
固定电话
0731-89565588