

























```html
<table id="tbl" class="easyui-datagrid" data-options="onRowContextMenu: function (e, rowIndex, rowData) {
$('#rightMenu').menu('show', { left: e.pageX, top: e.pageY }); e.preventDefault();
}
<th data-options="field:'code'">Code</th>
<th data-options="field:'name'">Name</th>
<th data-options="field:'price'">Price</th>
</table>
<div id="rightMenu" class="easyui-menu" style="width:100px;display: none">
<div iconCls="icon-xls" οnclick="exportData()">导出数据</div>
</div>
<script src="datagrid-export.js" charset="utf-8"></script>
<script>
// 导出轨迹点数据
function exportData(){
var tbl = $("#tbl");
var items = tbl.datagrid("getRows");
tbl.datagrid("toExcel", {
filename: "xxxx数据.xls",
rows: items,
worksheet: "Sheet"
});
</script>
```
e.preventDefault() 屏蔽浏览器自带右键菜单
datagrid右键菜单参考: https://blog.csdn.net/wh_forever/article/details/47154801
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。