Our blazing fast Grid component built with pure JavaScript


Post by MattSlalom »

I was looking into dispatching custom events, one of which was to trigger the context menu based on calling .trigger on the grid like so:

this.grid.trigger('contextMenu', {bubbles: true});

The menu isn't triggering, but I definitely feel like I am missing some pieces when compared to the built in event, but I also am not sure what is all required.

Any help would be appreciated


Post by mats »

By 'load' you mean show, right? Then it's not supported out of the box, we have this feature request open: https://github.com/bryntum/support/issues/868

Your idea to trigger synthetic events should work, look into dispatchEvent:

https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent

function simulateClick() {
  var evt = new MouseEvent("click", {
    bubbles: true,
    cancelable: true,
    view: window
  });
  var cb = document.getElementById("checkbox"); //element to click on
  var canceled = !cb.dispatchEvent(evt);
  if(canceled) {
    // A handler called preventDefault
    alert("canceled");
  } else {
    // None of the handlers called preventDefault
    alert("not canceled");
  }
}
document.getElementById("button").addEventListener('click', simulateClick);

Post Reply