Consider custom column target for New Row
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
They target the column you click on?
They currently do that. Perhaps it's useful to let you target, for example, always the first column. I'm thinking about this though.
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.
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
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.
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.
Fixed in 3.4.0