getting values before ending edit

4 posts, 0 answers
  1. Roger
    Roger avatar
    22 posts
    Member since:
    Nov 2017

    Posted 21 Dec 2017 Link to this post

    Hi,

    I want to do a validation of the values entered before ending the edit (i.e. if nothing was entered in 1 column or an item wasn't selected from a combobox then show a message and cancel the edit).

    Been trawling the forums and can't find the right advice...

  2. Dimitar
    Admin
    Dimitar avatar
    2713 posts

    Posted 22 Dec 2017 Link to this post

    Hello Roger,

    You can use the CellValidating event. For example:
    private void RadGridView1_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e)
    {
        if (e.Value == null)
        {
            e.Cancel = true;
            RadMessageBox.Show("Please enter value");
        }
    }
     
    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Roger
    Roger avatar
    22 posts
    Member since:
    Nov 2017

    Posted 01 Jan 2018 in reply to Dimitar Link to this post

    Hi Dimitar,

    unfortunately there are issues with this method as there are conflicts between the columns (I have 3) when editing and moving off the column.

    This table is included in a larger information collecting form.

    I think it would be better to have a separate procedure to check the columns before saving the whole form and then throw a message box if any remain empty.

    Thanks anyway.

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3210 posts

    Posted 02 Jan 2018 Link to this post

    Hello, Roger, 

    Thank you for writing back. 

    In the CellValidatingEventArgs you have access to the column. Hence, you can check not only the value but the column as well. Here is a sample code snippet:
    private void radGridView1_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e)
    {
        if (this.radGridView1.IsInEditMode && e.Column.Name == "your column name" && e.Value == null)
        {
            e.Cancel = true;
            RadMessageBox.Show("Please enter value");
        }
    }

    I hope this information helps. If you have any additional questions, please let me know. 

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top