I have a situation where I need the:
EditMode="GridEditMode.Incell"
but I also need to have an event trigger when the row is updated:
EditMode="GridEditMode.Inline"
There is no mode that supports both, what are my options?
I need to be able to trigger some action on a Cell by Cell update basis, but also need to trigger a specific action on a Row update.
Thoughts?
Robl
1 Answer, 1 is accepted
Hi Rob,
When using in-cell edit mode:
- There is no UI/UX concept for updating a row, because updates are made on a cell basis.
- At the same time, the OnUpdate event fires for the whole row even though the user updated a cell. So, from developer perspective the concept is for row updates even though you see the update cell (Field) in the event arguments.
I assume that you need to detect when:
- The user moves from one row to the next. Use the Grid OnEdit event and check if the Item property is different from the one in the last OnEdit execution.
- The user exits edit mode completely. Use OnCancel, OnUpdate and/or OnStateChanged and assume an edit mode exit if OnEdit does not fire in a short timeframe afterwards.
You can also consider batch editing where the user must explicitly confirm they have finished editing.
Regards,
Dimo
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
I'm not sure how OnEdit with Item property would identify a row has changed? If I click on the same column but a row below and it that has the same value as the row above, then that wouldn't show as a change? Unless you saying try to evaluate a index or key (which may not exist yet on a new row).
EDIT: In addition, I need to be able to prevent the row departure (aka args.IsCancelled) or cancel any changes they made to the row if they don't enter the required data for that row.
The issue is that I need to do specific validation on a row ONLY when they user attempts to move off the row. But I also need to do some cell processing when a user navigates from cell to cell on the same row. For example, I have two cells that are required but I don't want to keep hounding the user with validation error message on every cell update (aka OnUpdate when EditMode - InCell). I only want to hound the user with error message when they attempt to move off the row or anywhere outside the grid ... basically force them to complete the required cells data entry or cancel out.
I am essentially doing batch editing, but I still need to manage when validation messages should appear, some need to appear when a row is exited and some need to appear when a cell is exited.
Hi Rob,
The OnEdit event allows you to detect if the user has moved from one row to another row, given that the app has saved the previous edited row. This event does not expose information about changed values and that was not the idea. The most sensible place to check if cell value has changed is the OnUpdate event, which exposes a Field property in the event argument. You can compare the original value of the cell with the new value by using reflection or comparing all property values one by one.
Cell departure is allowed or restricted out-of-the-box, depending on the validation state of the edited cell. If you need to override the related user's behavior in some other way, use the Grid state to enter edit mode programmatically.
Overall, the described validation requirements are not compatible with in-cell editing, because the built-in validation triggers only for the edited cell. So, if you continue with this edit mode, you need custom validation and possibly custom rendering of validation messages.
Hi Dimo,
So basically, there is no support for this user requirement?
Our users will navigate to other cells in a grid on the same row in any order they so choose ... so to keep presenting a validation error because they haven't completed data entry into a cell yet in the row that requires data is extremely annoying for them ... if a row has 15 cells that requires data for 2 of the 15 cells, the validation prompt is tedious.
OnEdit wouldn't work even if I saved prior row as I would need to validate and prevent row departure if a cell has no data entered. OnEdit is triggered on cell entry not on exit.
What I'm looking for is an OnRowUpdate event from which I can then trigger the validation. Surely there must be some event Telerik grid can provide to detect an attempted row change and then allow me to do my custom validation and if not validate prevent the row change?
Hi Rob,
>> Our users will navigate to other cells in a grid on the same row in any order they so choose ... so to keep presenting a validation error because they haven't completed data entry into a cell yet in the row that requires data is extremely annoying for them ... if a row has 15 cells that requires data for 2 of the 15 cells, the validation prompt is tedious.
I agree that the scenario is tricky and have some relevant content in this regard in our documentation:
In in-cell edit mode, the OnAdd and OnCreate events fire immediately one after the other, unless OnAdd is cancelled. This means that:
- The new row is added to the Grid data source before users start editing it.
- Valid default values are recommended.
- Users are always editing existing rows, not adding new ones.
You can also consider some UX enhancements that can help in this scenario:
- Use custom popup editing for adding new rows in an in-cell editable Grid. Here is an identical custom popup editing example with a ListView.
- Define column Templates or column OnCellRender events that highlight the invalid cells in non-edit mode to the user or show a validation note inside.
>> What I'm looking for is an OnRowUpdate event from which I can then trigger the validation.
Even if such an event existed, it wouldn't make much sense for in-cell editing where each edit action for a specific cell fires OnUpdate and the Grid expects the app to update the value in the original data source immediately. So, the event would not represent a row update action, but a row leave (focus out) action. In the latter case, a more suitable potential built-in events are:
At the same time, a potential OnRowUpdate event is equivalent to the existing OnUpdate for the other edit modes, which is one more reason to not have it.
In scenarios where the validation spans over multiple related values, it may be better to use inline or popup editing, so that the user can consider and supply all editable properties at once and provide valid inputs with a single transaction.
>> Surely there must be some event Telerik grid can provide to detect an attempted row change and then allow me to do my custom validation and if not validate prevent the row change?
I assume that "row change" means "change of the focused row". In this case, the currently applicable information is in my previous replies.
>> OnEdit wouldn't work even if I saved prior row as I would need to validate and prevent row departure if a cell has no data entered. OnEdit is triggered on cell entry not on exit.
You can force edit mode for a different row or cell programmatically at any time.
