I have a RadGridView which contains one column which is for input, and this column contains a CellEditTemplate with several fields for input, like name, middle names and surname.
Name and surname must not be empty for the validation to pass. When I click to add new row, the form with these fields appear in view and I can edit them.
If I add text for the mandatory fields, name and surname and then click on other column in this new row, the validation passes and form collapses, which makes the row look as saved when its not.
This could have two solutions, either tell the user that the row is still in edit mode and its not saved, or just prevent the form from collapsing.
How can I do both things for example?
Display message that the row is still in edit mode, and prevent the form from collapsing if it is still in edit mode?
Note: I have cell validating event set, and also name and surname have "Required" data annotation attribute.
3 Answers, 1 is accepted
Would you find it possible to replicate your setup in a small sample project so that I can suggest a viable solution for your particular scenario? You can either open a new support ticket and attach the project there or upload it to a storage provider of your choice and share the download link.
If you do not find this possible, please share code snippets of the custom CellEditTemplate, how you handle the validation, and any piece of code you find relevant so that I can get a better understanding.
Thank you in advance for your cooperation on the matter. I will be awaiting your reply.
Here is a code snippet for the edit template. I the real case, it contains RadComboxBox and other fields.
I use cell validation. Previously it was on a complete row validation. But now since I have one cell with multiple input fields, cell validation
Thank you for the provided code snippets.
Based on them, I set up a small sample project to demonstrate a possible approach for achieving your requirement. It involves using the CellTemplateSelector property of the column and hooking it to a new property of the business object which determines whether they're being edited at the moment or not.
Do note that I've also bound the custom column to one of the properties and invoke a property changed notification to this property to reevaluate the cell template.
Please have a look and let me know if a similar approach would work for you. I will be awaiting your reply.
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.