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

Validating event fires twice for Color col

2 Answers 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 21 Jul 2016, 09:06 AM

Hi,

I'm binding a grid to a collection where one of the properties is of type 'Color'.

I want to validate the selected color, as only a subset of colors are allowed.

The validating event fires twice after changing the value of 'Color col' cell. And hence my msg box is shown twice. Any way around this?

private void StatusRadGridView_CellValidating(object sender, CellValidatingEventArgs e)
{
    if (e.ActiveEditor != null && e.ActiveEditor is GridColorPickerEditor)
    {
        Color c = (Color)e.Value;
        if(!AllowedColors.Exists(o=>o.Name == c.Name))
        {
            e.Cancel = true;
            RadMessageBox.Show(errorMsg);
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Jul 2016, 10:41 AM
Hello Thomas,

Thank you for writing.

I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to use the GridViewDataRowInfo.ErrorText which is designed approach for indicating errors when validation fails.

I hope this information helps. Should you have further questions I would be glad to help.


Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Thomas
Top achievements
Rank 1
answered on 21 Jul 2016, 10:49 AM

Hi Dess,

Thank you for the reply!

I know about the errortext option - In this case I just wanted to clearly notify the user about the allowed colors instead of them having to get the information from the error tooltip info.

Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or