Yes. That sounds exactly like what I'm attempting.
<div id="Grid"></div>
<script id="template" type="text/x-jsrender">
<button id=btn class="glyphicon"> click to show menu</button>
</script>
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
...
contextMenuSettings: { enableContextMenu: true},
columns: [
...
{ headerText: "Ship City", template:"#template" ,width: 80 },
],
templateRefresh: "refreshTemplate",
contextOpen: "contextOpen",
});
});
</script>
<script type="text/javascript">
//Trigger Context menu using the showContextMenu Method
function refreshTemplate(args) {
$(args.cell).find("#btn").click(function (e) {
var obj = $("#Grid_Context").ejMenu("instance");
//Grid is ID of the Grid + _Context
e.type = "mouseup";
e.which = 3;
var target = $(e.currentTarget).closest("tr").find(".e-rowcell:not('.e-templatecell')")[0];
obj.showContextMenu(null, null, target, e, true)
})
}
/*Prevents default functionality of the Context Menu Grid, menu opened only for the template element*/
function contextOpen(args) {
if (!$(args.events.target).hasClass("glyphicon"))
args.cancel = true;
}
</script>
|
Very nice and creative solution. Thank you very much for taking the time to show me this.
I'd like to work on the implementation a bit (1-2 days) before closing the ticket to ensure I don't have any related issues.