ValueChanged

4 posts, 0 answers
  1. Michael
    Michael avatar
    5 posts
    Member since:
    Mar 2012

    Posted 02 Feb 2017 Link to this post

    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

  2. Dimitar
    Admin
    Dimitar avatar
    2949 posts

    Posted 03 Feb 2017 Link to this post

    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.
  3. Michael
    Michael avatar
    5 posts
    Member since:
    Mar 2012

    Posted 03 Feb 2017 in reply to Dimitar Link to this post

    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?
  4. Dimitar
    Admin
    Dimitar avatar
    2949 posts

    Posted 03 Feb 2017 Link to this post

    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.
Back to Top