I have a DataGrid (currently the .NET 3.5 WPFToolkit version, but I can use the .NET 4.0 out-of-the-box DataGrid if needed) bound to a collection of objects. Three of the columns in the data grid represent pieces of information used as a key to grab other information from the database. This other information is used in calculations to populate other columns of the data grid.
Once the user enters these three fields, and the combination of the data in those fields exists in the database, the row is considered valid for adding to collection. The user is also now allowed to freely edit the other columns in the row. Once any other column is given data by the user, the three “key” fields are considered “locked” – the user may no longer edit them. The only way to change that information is to delete the entire row and add a new row.
1) What is the best way from a UX perspective to handle this? Should I allow the user to enter data in any column, “cache” their entries, then do my calculations all at once only after the “key” data is entered? Or should I restrict the user to only enter the “key” data first, then allow the user to enter data in the other columns?
2) What is the strategy (event handlers I need, etc.) for implementing the above in the data grid? How do I not allow the new row to be added to the data bound collection until it has valid “key” data, or do I allow the new row to be added with validation errors and somehow track that it is ok for the user to continue editing the “key” columns of the partially complete row, but not other existing rows in the data grid?
This is what I did for my particular situation:
1) The best way to handle this is to give the user the most flexibility possible. This means allowing the user to edit the key data under certain conditions, but not restricting the user to entering key data first.
2) The strategy for implementing that has two parts. First, define when the use is not allowed to edit the key data anymore, and add styles to the datagrid columns that switch the key value columns to a read-only mode based on a trigger. Second, when key data is changed, perform all of the logic behind-the-scene as if the row were deleted using the old key data and then created using the new key data. This will cover all of the side-effects I need to have happen.