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

perspective-view collapse / expand functions returning error #1656

Closed
ccarli opened this issue Dec 7, 2021 · 2 comments · Fixed by #1657
Closed

perspective-view collapse / expand functions returning error #1656

ccarli opened this issue Dec 7, 2021 · 2 comments · Fixed by #1657
Labels
bug Concrete, reproducible bugs JS

Comments

@ccarli
Copy link

ccarli commented Dec 7, 2021

Bug Report

I'm trying to use the perspective-view .collapse() method to displays the rows of my datagrid in a "grouped" state by default.
I'm not sure I'm using it correctly but when trying on one of the project's example I get the error message below

Steps to Reproduce:

  1. open Superstore example
  2. run in console
    viewer = document.querySelector("perspective-viewer[name='Sales Report']")  
    table = await viewer.getTable()
    view = await table.view()
    await view.collapse()

Expected Result:

update the datagrid display to group rows

Actual Result:

no action on datagrid and error message below

image

same behaviour / error message with methods .expand() and .set_depth()

@timkpaine timkpaine added bug Concrete, reproducible bugs JS labels Dec 7, 2021
@texodus
Copy link
Member

texodus commented Dec 7, 2021

Thanks for the report, @ccarli!

There are a few things conflated here. A View is kind of like a SQL query result set, but live - it holds the state and intermediate data for a set of query config values (e.g. what you put int he UI), including the expansions/collapse state of the tree (if it has one). The line view = await table.view() in your example creates a new View, e.g. not the one that your <perspective-viewer> UI created to render the data. That causes two issues:

  • This new View has no config options, it was instantiated without an argument in your example, View(). Thus it is un-pivoted, and has no tree to collapse or expand, thus the error. The error is unfortunately obtuse - we'll get that fixed.
  • Even if it had been pivoted, collapse()/expand() are being called on the wrong View, and won't affect the <perspective-viewer> UI as written.

In addition, you'll need to call .notifyResize(true) subsequently on the <perspective-viewer> to force it to redraw itself, because expand/collapse do not trigger data notifications (currently). So the correct code should look something like this:

viewer = document.querySelector("perspective-viewer[name='Sales Report']");
view = await viewer.getView();
await view.collapse();
await viewer.notifyResize(true);

... However, it appears the perspective-viewer re-write released in 1.0.0+ did not implement this method getView(), so this is not working in the most recent release yet (In versions <1.0.0, the .view property exists which allows this). I'll keep this report open to track this issue as well as the Error de-obfuscation issue above, these fixes should be in the 1.0.6 release.

@ccarli
Copy link
Author

ccarli commented Dec 7, 2021

Very clear, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Concrete, reproducible bugs JS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants