glide-data-grid icon indicating copy to clipboard operation
glide-data-grid copied to clipboard

Consider custom column target for New Row

Open ivoelbert opened this issue 4 years ago • 7 comments

Based on https://github.com/glideapps/glide-data-grid/issues/155

It might be useful to provide a way to target a specific column when adding a new row

ivoelbert avatar Feb 18 '22 16:02 ivoelbert

They target the column you click on?

jassmith avatar Feb 19 '22 04:02 jassmith

They currently do that. Perhaps it's useful to let you target, for example, always the first column. I'm thinking about this though.

ivoelbert avatar Feb 19 '22 22:02 ivoelbert

Oh I see... yeah that's not a bad idea at all. I like the way you think and would like to subscribe to your pull requests.

jassmith avatar Feb 19 '22 22:02 jassmith

If this is done at the trailingRowOptions level, would it make sense to target columns by index? (auto-correcting for row markers and such). If so, we could add that option to both the "global" trailingRowOptions and the per-column one.

For example, in a grid like

Name | Email | Photo

Passing the following

trailingRowOptions={{
    hint: "New Row",
    targetColumn: 0,
}}

would target the Name column no matter where you click on New Row

ivoelbert avatar Feb 19 '22 22:02 ivoelbert

The question really is do you care about the position or the actual column? If you care about the position (2nd col for example) then you want index. if you care about column (I always want to set the name) then you want to pass the actual column. Probably better to allow either.

jassmith avatar Feb 19 '22 22:02 jassmith

I thought about that, maybe index | GridColumn is a reasonable type for targetColumn. You'd need to pass in a reference to the column, cause we don't have column ids.

Anyways, the user chooses which columns to pass down to the data grid, so accepting a GridColumn doesn't open new possibilities, it's just for ergonomics... And arguably passing the index might be easier than dealing with references? 🤔 Still, supporting both doesn't seem like a bad idea.

ivoelbert avatar Feb 19 '22 22:02 ivoelbert

Fixed in 3.4.0

jassmith avatar Feb 22 '22 06:02 jassmith