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

Trigger Grid View Validation

2 Answers 121 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Minal
Top achievements
Rank 1
Minal asked on 24 May 2012, 08:51 AM
Is there a way to trigger the entire grid to validate all its rows from an external trigger like a button click which is outside of the grid. In our application the grid is dynamic i.e. columns are added dynamically so we are doing the row validations in the roweditvalidating event. But we also want to trigger validations when a Save button is clicked outside the grid.Is there an API we can use in the save click event handler that can trigger the entire grid to validate rows again or somehow trigger the roweditvalidating event for each row?

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 24 May 2012, 09:16 AM
Hello Minal Dharod,

I am afraid RadGridView does not provide such api . Validation may be triggered only on edit ending at cell and row level.

Regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Tim
Top achievements
Rank 1
answered on 24 Jul 2012, 12:23 PM
I had the same problem thus reading this thread was frustrating. However, I finally found a way to validate rows on demand:

void _viewModel_RequestValidation(object sender, EventArgs e)         
{             
    // force validation be setting all rows into edit mode and back.             
    foreach (TimeReportEntryViewModel timeReportEntryViewModel in _viewModel.TimeReports)
            {                 
                    GridViewRow item = (GridViewRow)MyGrid.ItemContainerGenerator.ContainerFromItem(timeReportEntryViewModel);
                   if (item != null)                 
                    {
                         (item.Cells[0] as GridViewCell).BeginEdit();
                         MyGrid.CommitEdit();
                    }
            }
}

It works for my requiremets so I wanted to share this with you.
Tags
GridView
Asked by
Minal
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Tim
Top achievements
Rank 1
Share this question
or