Datagrid添加工具栏:
var setList = {
title: '投票明细',
iconCls: 'icon-table',
serverPaging: true,
getServerData: this.loadVoteResultDetail,
toolbar: [{
iconCls: 'icon-edit',
text: '编辑',
handler: that.editVoteResult
},
{
iconCls: 'icon-help',
handler: function () { alert('帮助按钮');}
}],
columns: [[
{ field: 'USER_NO', title: '投票人', 200, align: 'center' },
{ field: 'VOTE_RESULT_ZQ', title: '债券等级', 200, align: 'center' },
{ field: 'VOTE_RESULT_ZT', title: '主体等级', 200, align: 'center' },
{
field: 'VOTE_RESULT_ZW', title: '展望', 200, align: 'center',
formatter: function (value) {
switch (value) {
case "0":
return "负面";
case "1":
return "稳定";
case "2":
return "正面";
default:
return "";
}
}
},
{ field: 'IMP_TIME', title: '投票时间', 200, align: 'center',align: "center" },
{ field: 'NOTE_CONTENT', title: '投票意见', 200, align: 'left' },
{
field: 'key', title: '操作', formatter: function (value, row, index) {
return "<a class='link' onclick='modVoteResultCtrl.delVoteResult("" + value + "");'>删除</a>"
}
}
]],
}
//创建投票明细数据表格
that.uiStore.gvVoteResultDetailList = $('#gvVoteResultDetailList').createDatagrid(setList);
定义方法:
editVoteResult: function () { var row = $('#gvVoteResultDetailList').datagrid('getSelected'); if (row) { console.log(row); console.log(row.RN); } }
结果: