我有一個包含項目的DataGrid。當您右鍵單擊其中一行時,會顯示一個Dojo上下文菜單,並帶有刪除該行的選項。如果您嘗試右鍵單擊DataGrid的空白區域,則不會顯示上下文菜單....但是,如果您先右鍵單擊一行,然後單擊取消菜單選項(不執行任何操作),或者如果您左鍵單擊頁面上的其他位置(隱藏上下文菜單),然後右鍵單擊DataGrid的空白區域,顯示上下文菜單IS,如果單擊上下文菜單中的刪除項目選項,它將刪除您右鍵單擊的最後一個項目。Dojo DataGrid上下文菜單onRowContextMenu即使在DataGrid的空白區域中右鍵單擊時也會顯示
爲什麼允許它的上下文菜單顯示,當你在一個空白區域的DataGrid但只有後你已經正確點擊DataGrid中的一個項目右擊?
任何提示將不勝感激。這裏是我的代碼到目前爲止:
var selectedItem; // This has to be declared "globally" outside of any functions
function onRowContextMenuFunc(e) {
grid5_rowMenu.bindDomNode(e.grid.domNode);
selectedItem = e.grid.getItem(e.rowIndex);
}
function gridRowContextMenu_onClick(e) {
store3.deleteItem(selectedItem);
}
。
<div dojoType="dijit.Menu" id="grid5_rowMenu" jsId="grid5_rowMenu" style="display: none;">
<div dojoType="dijit.MenuItem" onClick="gridRowContextMenu_onClick">Delete</div>
<div dojoType="dijit.MenuItem">Cancel</div>
</div>
。
<div id="grid" dojoType="dojox.grid.DataGrid" jsId="grid5" store="store3" structure="layoutStructure" rowsPerPage="40" onRowContextMenu="onRowContextMenuFunc"></div>