Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1590
Preventing edit mode from ending on row-base
posted

Hi, I'm trying to change the XamDataGrid's behavior, but I can't seem to get it working the way I want it to. The requirement is that, when a user is editing a row, the user should not be able to leave the row while it is invalid (and so it should stay in edit mode). However, the user should still be able to switch between cells because sometimes an object's validation state is determined by multiple properties (e.g. the From and Till properties in the sample).

The data object implements IDataErrorInfo and IEditableObject in order to support these functionalities.

Can you get my attached sample project working with these requirements?

Please take a look at Readme.txt, which is part of the Visual Studio solution. It contains more detailed technical information.

One more side question; when I set the wrong value for Icon (Red), and then press ESCAPE to roll back, I see some binding errors about PreDropDownAreaTemplate and PostDropDownAreaTemplate in the Visual Studio output window. Why is this?

Kind regards, Stefan

EditableObjects.zip
Parents
  • 35319
    Verified Answer
    posted

    Hello Stefan,

     

    Thank you for contacting Infragistics. I have been looking into your requirement and I managed to achieve it by handling to events of the XamDataGrid: ‘EditModeEnding’ and  ‘XamDataGrid_RecordDeactivating’. In the first one I am getting the latest edited cell in the XamDataGrid and after that canceling the deactivating of a particular record if there is not acceptable data :

     

       private void XamDataGrid_EditModeEnding(object sender, EditModeEndingEventArgs e)

            {

                activeCell = e.Cell;

            }

     

       private void XamDataGrid_RecordDeactivating(object sender, RecordDeactivatingEventArgs e)

            {

                if ((e.Record as DataRecord).DataError != null)

                {

                    e.Cancel = true;

                    this.dataGrid1.ActiveCell = activeCell;

                    this.dataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);

                }

            }

     

    I am attaching a modified version of your sample application(EditableObjects2.zip) that shows my approach.

     

    Let me know, if you need any further assistance on this matter.

    EditableObjects2.zip
Reply Children