Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to open context menu on right click, using Angular 7? #248

Closed
doll612 opened this issue Jul 27, 2019 · 6 comments · Fixed by #353
Closed

How to open context menu on right click, using Angular 7? #248

doll612 opened this issue Jul 27, 2019 · 6 comments · Fixed by #353

Comments

@doll612
Copy link

doll612 commented Jul 27, 2019

General Question, Topic

Your Environment

Software Version(s)
Angular 7.1.4
Angular-Slickgrid 2.9.8
TypeScript 3.1.6
Operating System win 10
NPM/Node/Yarn 6.4.1/10.13.0

Context

Expected Behavior

Current Behavior

Possible Solution

Code Sample

Thanks,

@doll612 doll612 changed the title How to open context menu on right click? How to open context menu on right click, using Angular 7? Jul 27, 2019
@ghiscoding
Copy link
Owner

ghiscoding commented Jul 27, 2019

Are you talking about this example, shown at the bottom?

I've never done any implementation or need such thing, but you can easily reproduce by using the SlickGrid grid object (and maybe the DataView object as well) directly. It's not a plugin or anything, it's just plain DOM element with jQuery events attached to them. I'm sure you can reproduce that easily, following the SlickGrid Context Menu code.

image

@coolrb
Copy link

coolrb commented Aug 16, 2019

We have implemented this functionality using a mix of jquery code.
First you need to define menu - html in your component like

<ul id="contextMenu" style="display:none;position:absolute">
   <b>Set priority:</b>
   <li data="Low">Low</li>
   <li data="Medium">Medium</li>
   <li data="High">High</li>
</ul>

And then define a method in your component to actually show the context menu

contextMenu(e) {
    console.log('Event ',e);
    e.preventDefault();
    const eventData = e.detail.eventData;
    var cell = this.angularGrid.slickGrid.getCellFromEvent(e);
    var x = e.pageX - 250;// $(e.target).offset().left;
    $("#contextMenu")
        .data("row", cell.row)
        .css("top", e.pageY)
        .css("left", x)
        .show();
    $("body").one("click", function () {
      $("#contextMenu").hide();
    });
}

And finally calling this in rowSelection event like
this.contextMenu(evt);
You need to have jquery installed

@ghiscoding
Copy link
Owner

Thanks for the code sample, I knew it wasn't that hard to implement with raw javascript/jQuery code.

You need to have jquery installed

jQuery is a dependency of this library, so you have no choice but to have it installed 😉

@ghiscoding
Copy link
Owner

not yet released it will come in the new year

@ghiscoding ghiscoding reopened this Dec 23, 2019
Repository owner deleted a comment from close-issue-app bot Dec 23, 2019
Repository owner deleted a comment from close-issue-app bot Dec 23, 2019
@ghiscoding
Copy link
Owner

ghiscoding commented Jan 6, 2020

@doll612 @coolrb
This is now live as a new feature. Check out latest version 2.15.x

Cheers ⭐️

@doll612
Copy link
Author

doll612 commented Jan 10, 2020

Thanks, @ghiscoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants