You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Table input's current sort order is only tracked internally. This poses a problem if a notebook author wants to persist the current sort state, e.g. via a permalink.
Suggested solution
When the sort column or order is changed, dispatch a custom sort event:
The instantiating cell can listen to click events and parse order and column name from event.target.textContent. This technique is error prone and expected to break once additional features (like custom table names) have been added.
Not sure if this is the same, but I think I was just experiencing this need. If I create a table like this:
viewofselected=Inputs.table(data)
selected won't change when I change the order of the element of the table by clicking on one of the columns. However, if selected some or all the rows using the checkboxes then the table order will be reflected on selected. It would be nice for the table to trigger an input whenever the table visual order changes
To follow up on this discussion, here is a video demonstrating my view of the problem. Inputs.Table should trigger the input event when the order changes. At least it should be configurable via options
@Fil I don’t think that’s quite enough; if there’s a selection, the selection should appear sorted, too. But currently it looks like the selection is ordered by the order in which rows were clicked.
I thought it worked because I had only tested sorting a selection; however I hadn't thought about adding elements to a selection while there is an "active" sort (which didn't work; now fixed).
Activity
[-]Expose current sort order[/-][+]Expose Table's current sort order[/+]john-guerra commentedon Mar 27, 2022
Not sure if this is the same, but I think I was just experiencing this need. If I create a table like this:
selectedwon't change when I change the order of the element of the table by clicking on one of the columns. However, if selected some or all the rows using the checkboxes then the table order will be reflected onselected. It would be nice for the table to trigger aninputwhenever the table visual order changesjohn-guerra commentedon Apr 26, 2022
To follow up on this discussion, here is a video demonstrating my view of the problem.
Inputs.Tableshould trigger theinputevent when the order changes. At least it should be configurable via optionshttps://observablehq.com/d/297b6d84743974ae
Fil commentedon Apr 30, 2022
@john-guerra's suggestion would be consistent with what Inputs.table does when passed a sort option; I wonder if we couldn't just do the following:
demo at https://observablehq.com/@fil/table-sort-115 ; this also allows to listen to the input event and check if it's a sort event, addressing @mootari's request.
mbostock commentedon Apr 30, 2022
@Fil I don’t think that’s quite enough; if there’s a selection, the selection should appear sorted, too. But currently it looks like the selection is ordered by the order in which rows were clicked.
Fil commentedon May 2, 2022
I thought it worked because I had only tested sorting a selection; however I hadn't thought about adding elements to a selection while there is an "active" sort (which didn't work; now fixed).
dispatch the value on sort events, with details allowing to read the …