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

Selection Prompt on Grid #1566

Open
rickdgray opened this issue Jun 11, 2024 · 3 comments
Open

Selection Prompt on Grid #1566

rickdgray opened this issue Jun 11, 2024 · 3 comments

Comments

@rickdgray
Copy link

rickdgray commented Jun 11, 2024

Is your feature request related to a problem? Please describe.

The selection prompt has a converter for displaying, but it's dependent on the developer to handle padding, etc. for options. The grid and table constructs have excellent padding and display abilities but no easy way to make a choice from the rows.

Describe the solution you'd like

I would like to be able to pass a grid (or even a table) into the selection prompt so that I may have a cursor on the grid to make a selection from those rows as options.

Describe alternatives you've considered

I have tried doing the two separately: display the grid, then have a selection below it. Because the padding will be difficult to get to match the grid, the alignment is wrong. Further, the data is redundant. I don't want to have to scroll through a list of data that I'm already looking at in a grid.

Another possibility is using numbers or IDs to distinguish each option. This isn't very feasible though when there are too many options to fit on a single screen. The scrolling functionality applied to a grid would be very helpful.

Something else I've tried: typing in a selection based on only one column of the grid. This isn't very feasible for the same reason I want to display as a grid: no one single column is guaranteed unique. I have to display multiple columns.

Additional context

What I am trying to do is simplify the updating of my DNS records through my name registrar's API. Here's a screenshot with some anonymized data:

image

As you can see, displaying the data as a grid is perfect, but I would really like the selection cursor to just be on the grid itself, not as a separate option below.


Please upvote 👍 this issue if you are interested in it.

@gle-hrweb
Copy link

I did a quick and dirty TableSelectionPrompt project yesterday but I had to copy a lot of internal files from the main project, it would probably be better to generalize a bit the existing SelectionPrompt/MultiSelectionPrompt and avoid duplicating that much code. Here's my project: https://github.com/guillaume86/spectre.console/tree/main/src/Spectre.Console.GridPrompt it's just some demo code, a proper merge request would be completely different.

image

image

@rickdgray
Copy link
Author

Amazing, this is exactly what I'm looking for!

@guillaume86
Copy link

@patriksvensson would you consider a PR to generalize SelectionPrompt/MultiSelectionPrompt from list to grid? The API could remain backward compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo 🕑
Development

No branches or pull requests

3 participants