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

Add perspective-click event to grid #1250

Merged
merged 1 commit into from
Dec 21, 2020
Merged

Add perspective-click event to grid #1250

merged 1 commit into from
Dec 21, 2020

Conversation

Sam-Ogden
Copy link
Contributor

Fixes #1076
This PR adds the perspective-click event to perspective-viewer-datagrid as specified in the docs.

@Sam-Ogden Sam-Ogden requested a review from sc1f November 9, 2020 10:13
@finos-cla-bot
Copy link

finos-cla-bot bot commented Nov 9, 2020

Thank you for your contribution and Welcome to our Open Source Community!

To make sure your pull request is accepted successfully, we ask all our open source contributors to sign a Contributor License Agreement.

Having reviewed our contributor list, we require a CLA for the following people : (@Sam-Ogden).

If you need help obtaining a CLA, please read the Requirements for Contributions section of our CLA wiki or email [email protected] with your questions.

Thanks once again for your contribution. Let us work with you to make the CLA process quick, easy and efficient so we can move forward with reviewing and accepting your pull request.

cc @finos-admin

Copy link
Contributor

@sc1f sc1f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally - looks great, works well for arbitrary pivots and filters. Thanks!

@KrishnaPG
Copy link

Came across this while facing a problem with click. The click event is not being raised. Used the below code from the [documentation)(https://perspective.finos.org/docs/md/js.html), but event is not getting triggered.

elem.addEventListener("perspective-click", function(event) {
    var config = event.detail.config;
    elem.restore(config);
});

Then came across this PR. Wondering if the click functionality is available yet. If not, could some one kindly merge this PR if this is what enables that click functionality specified in the documentation?

@texodus
Copy link
Member

texodus commented Dec 21, 2020

Thanks for the PR! Apologies for the delay in merging, this is a much-requested feature addition.

Following the pattern of existing perspective-* events for click is a natural addition to the existing API. Orthogonal to this PR (and also completely undocumented ..), ideally this would not be necessary, as we use the Custom Elements API to avoid needing to recreate DOM-like functionality. click is a good example of this:

const viewer = document.querySelector("perspective-viewer");
const table = document.querySelector("perspective-viewer regular-table");
viewer.addEventListener(x => {
    console.log(table.getMeta(x.target));
});

As it stands however, this is not particularly useful for a few reasons:

  1. You must do this separately for each plugin type.
  2. It is difficult to get the cell "config", a metadata dictionary of a single coordinate in a View.

For the latter at least, I propose getCellConfig() should move to @finos/perspective and perhaps undergo a name change.

@texodus texodus merged commit 31a2700 into master Dec 21, 2020
@texodus texodus deleted the grid-perspective-click branch December 21, 2020 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

perspective-click event on perspective-viewer-datagrid
4 participants