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

ValueChanged

3 Answers 172 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 02 Feb 2017, 09:13 PM

I have a form with a grid that contains just a combobox and I'm wondering what is the proper way to have that value stick, by stick I mean causing the CellValueChangedEvent, when I select a value in the list and then move to another control.

The relevent events that get fired are:

ValueChanging

ValueChanged

and then the next event is

Leave

I've played around with calling EndEdit, however I don't believe I'm calling it at the right point.

 

In the _Leave event I get the new row as

var newRow = lstData.CurrentRow as GridViewNewRowInfo, however the Cells["ComboColumn"].Value is null and this is becuase CellValueChanged hasn't fired yet.

-Michael

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 03 Feb 2017, 09:06 AM
Hello Michael,

I have tested this and the CellValueChanged event is fired after the Leave event on my side. Does this event fires on your side at all? Or you expect it to fire before the Leave event?

I have attached my test project as well.

I am looking forward to your reply. 

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jason
Top achievements
Rank 1
answered on 03 Feb 2017, 01:07 PM
I was expecting it before the leave event.  In my case I wanted to detect the change and prompt the user that the record has changed so that they could ignore, save the change, or cancel and not move from the current control / focus.  If the leave event fired do I just need to code it to bring focus back to where they were?
0
Dimitar
Telerik team
answered on 03 Feb 2017, 01:56 PM
Hello Michael,

You can use the UserAddingRow event to either accept the new row or cancel the change. Please note that the current cell would not be changed when the grid loses the focus:
private void RadGridView1_UserAddingRow(object sender, GridViewRowCancelEventArgs e)
{
    var row = e.Rows[0] as GridViewNewRowInfo;
 
    if (row.Cells[0].Value == null)
    {
        e.Cancel = true;
        RadMessageBox.Show("Enter Valid Value!");
 
    }
    else
    {
        RadMessageBox.Show("New row will be added. Value: " + row.Cells[0].Value);
    }
 
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Jason
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Jason
Top achievements
Rank 1
Share this question
or