首页 > 代码库 > 表格右键菜单

表格右键菜单

 

 

 //窗体加载事件                $(window).load(function () {                    $(#mm).menu({                         onClick: function (item) {                            if(item.id == createLeftTable){                                self.createLeftTable();                            }                            else if(item.id == createRuleLeftTable){                                self.createRuleLeftTable();                            }else if(item.id == createExtRuleRightTable){                                self.createExtRuleRightTable();                            }                                                      }                    });                }); 
//生成左表数据(推送)                this.createLeftTable=function(){                    var row = self.grid.datagrid(getSelected);                    if (!row) return snf.message(warning, self.resx.noneSelect);                    var index = self.grid.datagrid(getRowIndex, row);                      //数据提交                    snf.ajax({                        url: /api/DEMO/DemoSingleTable/CreateLeftTable,                        data: ko.toJSON(row),                        success: function (d) {                            snf.messageif(d.msgtype != ‘‘, d.msgtype, d.msg);                         }                    });                }                //生成左表数据(规则)                this.createRuleLeftTable=function(){                    var row = self.grid.datagrid(getSelected);                    if (!row) return snf.message(warning, self.resx.noneSelect);                    var index = self.grid.datagrid(getRowIndex, row);                    //数据提交                    snf.ajax({                        url: /api/DEMO/DemoSingleTable/CreateRuleLeftTable,                        data: ko.toJSON(row),                        success: function (d) {                            snf.messageif(d.msgtype != ‘‘, d.msgtype, d.msg);                         }                    });                }                //生成右表数据(扩展规则)                this.createExtRuleRightTable=function(){                    var row = self.grid.datagrid(getSelected);                    if (!row) return snf.message(warning, self.resx.noneSelect);                    var index = self.grid.datagrid(getRowIndex, row);                    //数据提交                    snf.ajax({                        url: /api/DEMO/DemoSingleTable/CreateExtRuleRightTable,                        data: ko.toJSON(row),                        success: function (d) {                            snf.messageif(d.msgtype != ‘‘, d.msgtype, d.msg);                         }                    });                }

 

 this.grid = {                    ////size: { h: 40 },//120                    size: { w: 4, h: 94 },                    url: self.urls.query,                    queryParams: ko.observable(ko.toJS(this.queryForm)),                    pagination: true,                    onRowContextMenu:  function (e, rowIndex, rowData) { //右键时触发事件                                              $(this).datagrid("clearSelections"); //取消所有选中项                        $(this).datagrid("selectRow", rowIndex); //根据索引选中该行                        e.preventDefault();                         $("#mm").menu(show, {                                                          left:e.pageX,                            top:e.pageY                        });                              },                };  

 

<div id="mm" class="easyui-menu" style="width: 65px;">    <div id="createLeftTable" data-options="iconCls:‘icon-package‘">生成左表数据(推送)</div>    <div id="createRuleLeftTable" data-options="iconCls:‘icon-package_add‘">生成左表数据(规则)</div>    <div id="createExtRuleRightTable" data-options="iconCls:‘icon-package_down‘">生成右表数据(扩展规则)</div></div>

 

表格右键菜单