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

[Lens] Client side table sorting #76962

Closed
flash1293 opened this issue Sep 8, 2020 · 4 comments · Fixed by #84435
Closed

[Lens] Client side table sorting #76962

flash1293 opened this issue Sep 8, 2020 · 4 comments · Fixed by #84435
Assignees
Labels
enhancement New value added to drive a business result Feature:Lens Project:LensDefault Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@flash1293
Copy link
Contributor

flash1293 commented Sep 8, 2020

The table visualization in Lens should be sortable on the client side similar to the legacy data table visualization is handling that. Clicking on the table header will change the sorting and sort the existing rows by the clicked column, rendering an indicator how it's sorted at the moment. This client side sorting should only be available in the Lens editor, not on dashboards. The information about client side sorting is stored in the visualization state of the table.

Open questions / architecture changes:

There is a separate issue about server side sorting which is pushed out for now: #55905

@flash1293 flash1293 added enhancement New value added to drive a business result Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Sep 8, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@flash1293
Copy link
Contributor Author

flash1293 commented Sep 15, 2020

Proposal:

  • Implement Make expression renderer aware of current context #77161 for expressions and pass the current mode through in embeddable, workspace panel and suggestions
  • In table, allow clicking the column headers to sort client side when mode is set to edit
  • When clicked, call handlers.event on the expression renderer with a custom event type ({ name: 'editAction', data: { action: 'sort', columnId, order: 'desc' } }). The name of the action will be defined at Lens editor frame level, while the specific visualization controls the private data payload. This way each visualization can use the mechanism to pass arbitrary events back to its own state handling
  • Extend the Visualization interface by onEditAction?: (state: T, editAction: A) => T (A being a new optional type param)
  • If the expression event handler is called with an editAction in the workspace and the currently active visualization includes an onEditAction, call it with the current state and the event payload and update the visualization state accordingly
  • Use this newly introduced API in the table visualization to store the current client side sorting state as part of the regular visualization state
  • In the toExpression function of the datatable visualization, use the current client side sorting state to write an expression using the existing canvas sort function: https://www.elastic.co/guide/en/kibana/master/canvas-function-reference.html#sort_fn
  • Pass the client side sorting state to the render function as well to render triangle sorting indicators in the table
  • Sorting is shown to the user as a "three state" toggle (this is how visualize and discover are doing it as well). Default: Not sorted by the column, 1 click: Sorted descending by the column, 2 clicks: Sorted ascending by the column, 3 clicks: Not sorted by the column again

Open questions about architecture:

Open questions about feature:

  • Should it be possible to sort by multiple columns at once? Discover is doing it, Visualize is not doing it, so it's not really possible to stay consistent

@flash1293
Copy link
Contributor Author

We will start only allowing single column sorting for now similar to the Visualize data table

@flash1293 flash1293 added the loe:needs-research This issue requires some research before it can be worked on or estimated label Sep 21, 2020
@flash1293 flash1293 removed the loe:needs-research This issue requires some research before it can be worked on or estimated label Sep 30, 2020
@flash1293 flash1293 self-assigned this Nov 17, 2020
@flash1293 flash1293 removed their assignment Nov 25, 2020
@dej611 dej611 self-assigned this Nov 25, 2020
@dej611
Copy link
Contributor

dej611 commented Dec 15, 2020

Open specific issues for IP and range data types specific sorting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:Lens Project:LensDefault Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants