[Solved] GridView Data Annotation Issues on Filter Rows

0 Answers 5 Views
GridView
Luke
Top achievements
Rank 1
Luke asked on 18 Nov 2026, 09:17 PM

Product: Telerik UI for WinForms, RadGridView Version: 2026.4.1111 (2026 Q4). Regression: not present in 2026.3.812 (Q3), which has no GridViewDataAnnotationHelper. Framework: .NET Framework 4.8, Windows 11 Attachment: GridAnnotationRepro.zip, a minimal WinForms project with a manual repro and a scripted --selftest mode

Summary

2026 Q4 added data annotation validation to the end of a cell edit: GridViewEditManager.EndEditCore → RaiseCellValidatingEvent(..., validateAnnotations: true) → GridViewDataAnnotationHelper.TryValidate. That validation also runs on the filter row. It checks the text typed in a filter cell against the bound property's ValidationAttributes as if it were a value for that property. When the check fails, the editor silently stays open. The grid then refuses row changes, and the parent form refuses to close. No exception is thrown, CellValidating is not cancelled, and the user sees no message. Only Esc recovers.

With a [Required] string property, just clicking into its empty filter box and clicking elsewhere locks the form.

Steps to reproduce

  1. Bind a RadGridView with EnableFiltering = true to a BindingList<T> whose type has a [Required] public string Name { get; set; } property.
  2. Run the form, click into the filter cell under Name, and leave it empty.
  3. Click a data row, or call Close() on the form.

Expected: the filter editor closes (an empty filter means "no filter"), the row is selected, and the form closes. This is the 2026 Q3 behavior.

Actual:

  • RadGridView.EndEdit() returns false and the editor stays open.
  • The data row highlights on hover but cannot be selected (CurrentRow assignment is refused).
  • Form.Close() is refused because form validation fails.
  • CellValidating fires with Cancel = false. The only trace is ErrorText = "The Name field is required." on the filter cell, which is not displayed.

Scripted results on 2026.4.1111.48 (from the attached --selftest)

CaseResult
Filter row, [Required] Name, left emptyLocked: EndEdit=false, row change refused, Close refused
Filter row, [Required(AllowEmptyStrings = true)] Nickname, left emptyLocked
Filter row, [EmailAddress] Email, partial search text "alice"Locked ("not a valid e-mail address")
Filter row, City (no attributes), left emptyOK (control)
Data cell, [Required] Name = "", opened and left without changesLocked
Data cell, [Required(AllowEmptyStrings = true)] Nickname "Al", cleared to ""Locked
Data cell, [Required(AllowEmptyStrings = true)] Nickname = "", opened and left without changesOK
Data cell, City (no attributes), opened unchanged / cleared to ""OK (controls)

Problems we see

  1. Filter cells are validated as model values. Filter input is search criteria, not a property value. Any [Required], [MinLength], [RegularExpression], [EmailAddress], [Phone], [Range], etc. on a bound property makes ordinary filtering (an empty box, a partial value, an out-of-range value used to find bad rows) lock the grid. TryValidate should not run for GridViewFilteringRowInfo / GridFilterCellElement.
  2. The failure is silent and spreads. The editor stays open with no visible message, no exception, and no cancelled CellValidating. As a result, row changes and the parent form's Close() are refused. An application has no event to see this happening or handle it.
  3. AllowEmptyStrings = true has no effect on editor values. EndEditCore converts string.Empty to null before validating, so a user clearing a cell (or an empty filter box) fails even when the model explicitly allows empty strings.
  4. Unchanged cells are validated too. Opening a cell that already holds an invalid value (for example legacy data) and leaving it without typing anything locks the editor. The user only clicked into the cell, and the only way out is Esc.
  5. There is no opt-out. The feature is on by default in a quarterly release, and we found no property to disable it. We worked around it by subclassing GridViewEditManager, overriding EndEditCore to raise CellValidating ourselves, then calling base.EndEditCore(false, cancel), and installing it through RadGridViewElement.EditorManager. This relies on internal behavior.

Requests

  • Skip annotation validation for the filter row.
  • Add a property to turn annotation validation off (per grid, or RadGridView-wide), and consider defaulting it to off for existing apps.
  • When annotation validation fails, surface it: set CellValidatingEventArgs.Cancel = true so handlers can see and override it, or show the error. Don't silently keep the editor open.
  • Honor RequiredAttribute.AllowEmptyStrings by validating the editor's value before the "" → null conversion.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Luke
Top achievements
Rank 1
Share this question
or