Declined
Last Updated: 01 Oct 2018 12:48 by ADMIN
Stefan
Created on: 24 Sep 2018 08:26
Category: UI for WPF
Type: Feature Request
0
GridView: Control/force validation of cells other than current OR some feature to enforce unique values in a column
Short version of feature request: 
It would be nice to be able to enforce unique value in a column in an MVVM environment?

Long version of request:
To enforce a unique value in a column I ended up with a custom ValidationAttribute in the data model. Very much like the last example in the old thread 
https://www.telerik.com/forums/force-validation-on-new-record-insert

Direct link to the example provided by Telerik:
https://www.telerik.com/clientsfiles/375715_328546-TestApp-new.zip 

At a first glance, the solution seems to work, but if you edit a value in a cell and the new value is the same as another cell in the same column, BOTH these cells would have an error. Not just the cell you edited. I understand that not all cells can be validated whenever a single cell is edited, but it would nice if there was way to configure the RadGridView to “refresh” validations of all visible cells when a validation error is either set or removed?

I do not know if a solution like this would fit the internal design of the RadGridView, but it might give you some inspiration :-)

Add an attribute to the column definitions in the GridView:
ValidationTransitionMode= Default | ForceValidationOfAllVisibleCellsInColumn | ForceValidationOfAllVisibleCells

Default: 
No change from existing functionality.

ForceValidationOfAllVisibleCellsInColumn: 
Whenever a validation result of a cell changes (from no_error to error OR from error to no_error) all the visible cells in the column will be re-validated. This would do the trick to enforce uniqness in a column with a custom ValidationAttribute.

ForceValidationOfAllVisibleCells: 
Whenever a validation result of a cell changes (from no_error to error OR from error to no_error) all the visible cells of the complete grid will be re-validated. To be used by people with more complex validation algorithms depending on values in other columns as well.


Steps to visualize the current problem.
◦Run the example (https://www.telerik.com/clientsfiles/375715_328546-TestApp-new.zip )
◦When the application is running, reduce the window height (from the bottom) so that the scroll bar is visible and the top visible row shows “last name”=”Rockhead 0” and the bottom visible row shows “Rockhead 4”.
◦Change last name “Smith 3” to “Smith 1”.
◦Now there is a red border around the cell we edited (as expected) but nothing happens to row 2 (First name=Jane1).
◦Scroll to the bottom and back up to the top.
◦Now there is also an error on row 2 (First name = Jane1).
◦Change “Smith 1” back to “Smith 3” (on the row where First name=Jane 3).
◦The error on the cell edited is now removed, BUT the error on row 2 (Jane 1) is still visible even as all values in the Last name column is now unique.

I got some very good support and a suggestion to modify the control template, but it would still be nice to be able to control the validation execution of cells, other than the current cell.

Complete information can be found in the forum thread:
https://www.telerik.com/forums/enforce-unique-content-in-a-column-using-mvvm#4qSllj_EKkecS6ZtctdwAw 

Regards
/Stefan
1 comment
ADMIN
Vladimir Stoyanov
Posted on: 01 Oct 2018 12:48
Hello Stefan,

Thank you for the detailed description.

After carefully reviewing the described scenario and discussing it with our development team, we agreed that such custom validations should be performed on the data level and not on the control level.

That said, I do hope that the suggested approach in the referenced topic would work for you: https://www.telerik.com/forums/enforce-unique-content-in-a-column-using-mvvm#GnkWqppgn0W_PqRnPAIhbQ. 

Should you have any additional questions or concerns, you can open a new support ticket / forum thread and ask them there.

Best regards,
Vladimir