This is a migrated thread and some comments may be shown as answers.

GridView - Async Validation not "updating"

5 Answers 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 17 Apr 2011, 10:27 PM
I have a datagrid bound to RIA / DDS.Data.  Metadata validation is coming through and the cell correctly indicates when an incorrect entry is entered (highlight), and the information is correctly passed to the validation summary all asynchronously.

When the cell is then "corrected" with an acceptbile value (basis Metadata), the cell correctly removes the highlight indicator however validation summary is not being updated (cleared).

In the event I'm missing something, I didn't want to log a bug.
I'm on version 2011.01.315.0

Thanks.

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Apr 2011, 08:42 AM
Hi Mark,

May you share a bit more information about the exact scenario you are trying to achieve ? What exactly do you refer to as "validation summary", is it something like the one in our demos for RowValidation?
If yes, please take a look at the code-behind - there the errors in the validation summary are cleared on RowValidated event:

void radGridView_RowValidated(object sender, Telerik.Windows.Controls.GridViewRowValidatedEventArgs e)
        {
            this.validationSummary.Errors.Clear();
            foreach (GridViewCellValidationResult valResult in e.ValidationResults)
            {             
            }
        }


Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 21 Apr 2011, 12:42 PM
Hi Maya,

The components involved are the RadDataGrid, and a generic Silverlight ValidationSummary from the SDK.  The first column in the grid is a "quantity" field with associated validation metadata on the WCF RIA side.  I've attached screenshots of the conditions.

If the cell has a value (e.g. 5), we have a validation and the screen is clear.

If I edit that cell with a value (e.g. change 5 to AAA), tab to the next field, we have a failed validation and the cell turns RED with information and the error is listed into the ValidationSummary.  This is done without code and asynchronously.  The row is still in the editing state.  Only the current cell has been changed.

If I then correct the cell with a value (e.g. change AAA back to 5), still within the same editing row, the cell asynchronously updates, the RED border disappears.  However the error remains within the SummaryValidation. 

I guess I am surprised I would have to explicitly remove the error on a subsequent "positive" validation as I didn't have to explicitly add it. 

I've tried the following code as provided in the demo, however the condition remains:
private void dg_tblPOLines_RowValidated(object sender, GridViewRowValidatedEventArgs e)
       {
           this.valSummary.Errors.Clear();
           foreach (GridViewCellValidationResult valResult in e.ValidationResults)
           {
               GridViewCell errorCell = e.Row.GetCellFromPropertyName(valResult.PropertyName);
               ValidationSummaryItemSource validationSummaryItemSource = new ValidationSummaryItemSource(valResult.PropertyName, errorCell);
               this.valSummary.Errors.Add(new ValidationSummaryItem(valResult.ErrorMessage, string.Empty, ValidationSummaryItemType.ObjectError,
                   validationSummaryItemSource, e.Row.DataContext));
           }
       }


Thanks,
Mark
0
Maya
Telerik team
answered on 26 Apr 2011, 01:25 PM
Hi Mark,

In the scenario you described, the validation is handled by the Framework and it fails at cell level, not when the whole row is validated. Consequently, you may try to execute a similar code in the CellValidated event. I am sending you a sample project illustrating the suggested approach. Please take a look at it and let me know whether it corresponds to your scenario. 

Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 28 Apr 2011, 11:40 AM
Hi Maya,

Thank you for your efforts, unfortunately this doesn't resolve the issue.  If you'll try your sample, you'll see that the cell validation is removed from the validation summary, however the overall validation summary "notice" is still evident until the row validates at which point the validation is cleared and removed from the UI.

The standard SL SDK datagrid required none of this additional plumbing and I find it surprising and frankly counterproductive that from the coding perspective I need to address this so granularly.  If it is a function of the additional abilities provided by the telerik grid (which I certain agree is superior) than so be it. 

It just seems to be significantly "more" work not less to implement validation in your control.
0
Maya
Telerik team
answered on 29 Apr 2011, 10:11 AM
Hi Mark,

You are quite correct. This behavior is observed as no matter if there is an error or not, such is being added to the validation summary items source. What you may do is to slightly change the implementation of the CellValidated event:

void clubsGrid_CellValidated(object sender, GridViewCellValidatedEventArgs e)
        {
            this.validationSummary.Errors.Clear();     
            GridViewCell errorCell = (e.Cell.ParentRow as GridViewRow).GetCellFromPropertyName(e.ValidationResult.PropertyName);
            ValidationSummaryItemSource validationSummaryItemSource = new ValidationSummaryItemSource(e.ValidationResult.PropertyName, errorCell);
            if (validationSummaryItemSource.Control != null)
            {
                this.validationSummary.Errors.Add(new ValidationSummaryItem(e.ValidationResult.ErrorMessage, string.Empty,
                                                                                ValidationSummaryItemType.ObjectError,
                                                                                validationSummaryItemSource, (e.Cell.ParentRow as GridViewRow).DataContext));
            }
        }
 
Let me know whether it corresponds to your requirements.

Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Maya
Telerik team
Mark
Top achievements
Rank 1
Share this question
or