日期:2014-05-16 浏览次数:20365 次
<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>
<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>
//添加右击菜单内容
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){
........
}
***/
}
var datarow = $('#grid').datagrid('getSelections');
if (datarow == null
------解决方案--------------------
datarow.length <= 0) {
showmsg("请选择要编辑的记录!");
&nbs