我想查看单行数据(如ID为20)的右键上获取该行的值,代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<script type=
"text/javascript"
>
$(
function
(){
$(
'#test'
).datagrid({
title:
'DataGrid数据列表'
,
iconCls:
'icon-grid'
,
fit:
true
,
collapsible:
true
,
closable:
true
,
nowrap:
false
,
animate:
true
,
url:
'<%=rootPath%>data/getJobs'
,
idField:
'id'
,
pagination:
true
,
pageSize:20,
pageList: [10,20,30,40,50,100],
onRowContextMenu: onRowContextMenu,
//右键。[表头(tab)右键onHeaderContextMenu,树形(tree)右键onContextMenu]
rownumbers:
true
,
singleSelect:
true
,
columns:[[
{title:
''
,field:
'ck'
,width:120,checkbox:
true
},
{field:
'id'
,title:
'岗位ID'
,width:80},
{field:
'job_name'
,title:
'岗位名称'
,width:80},
{field:
'dat'
,title:
'入职日期'
,width:80,align:
'right'
},
{field:
'work_address'
,title:
'工作地点'
,width:80},
{field:
'salary'
,title:
'薪资'
,width:80,align:
'right'
},
{field:
'status'
,title:
'状态'
,width:60},
]],
onLoadSuccess:
function
() {
delete
$(
this
).datagrid(
'options'
).queryParams[
'id'
];
}
});
});
</script>
|
右键菜单:
1
2
3
4
5
6
7
8
9
|
<
div
id
=
"mm"
class
=
"easyui-menu"
style
=
"width:120px;"
>
<
div
onClick
=
"view()"
data-options
=
"iconCls:'icon-search'"
>查看</
div
>
<
div
onClick
=
"add()"
data-options
=
"iconCls:'icon-add'"
>新增</
div
>
<
div
onClick
=
"edit()"
data-options
=
"iconCls:'icon-edit'"
>编辑</
div
>
<
div
onClick
=
"del()"
data-options
=
"iconCls:'icon-remove'"
>删除</
div
>
<
div
class
=
"menu-sep"
></
div
>
<
div
onClick
=
"print()"
data-options
=
"iconCls:'icon-print'"
>打印</
div
>
<
div
onClick
=
"reload()"
data-options
=
"iconCls:'icon-reload'"
>刷新</
div
>
</
div
>
|
javascript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//添加右击菜单内容
function
onRowContextMenu(e, rowIndex, rowData){
e.preventDefault();
var
selected=$(
"#test"
).datagrid(
'getRows'
);
//获取所有行集合对象
selected[rowIndex].id;
//index为当前右键行的索引,指向当前行对象
$(
'#mm'
).menu(
'show'
, {
left:e.pageX,
top:e.pageY
});
}
//查看详细
function
view(){
/***
就是这里获取单行数据方法????
treeGrid上倒是很好实现:
var node = $('#datagrid').treegrid('getSelected');
if(node){
........
}
***/
}
|