We are using WPF infragistics version 2014.2.
We are facing an issue while working on the XamDatagrid. In our application we have two grids (parent and its child). Based on the record selected in the parent grid the child grid is loaded. In the parent grid we can add new records or edit the existing records. However before performing committing the record we need to perform few validations. Following are the validations that we need on the parent grid.
- The name column of the parent grid is compulsory, so it cannot be blank. - Also the name should not be duplicate.
We have used the "EditModeEnding" event to perform these validation checks. However we found that when the user either adds duplicate name or makes the cell blank; and then if he clicks on the child grid, though the validations are performed and the message box is displayed still the parent grid’s row is committed.
As per our requirement we want that when the validation fails the focus should be set on the parent grid’s column until the user rectifies the value. We have attached herewith a test application with the sample code that we are using to perform these validation. You test the above mentioned issue with the “Module Issue” tab of the test application. Please let us know is there any way we can restrict the user and set the focus back on the parent grid’s cell till the validations checks are successful.
Hi rhealsoftTakeoff,
I was able to reproduce this issue in an isolated sample where the EditModeEnding event is fired recursively when e.Cancel is true so I logged a development issue to have one of our engineering staff examine this further. In order for you to view the status of this development issue, I have created a private case for you which you can access here. The case number is CAS-148833-F0K9G3.
We have made further few more changes in our test application, such that if the validation check is failed we revert back the value of the cell to the previously set value. However even after reverting the values, if we click on the child grid the values are somehow committed to the grid collection.
Further, we had tried setting the e.cancel ='True', however as mentioned above after setting this value the validation is raised recursively.
As per our requirement if the validation check is failed and the user clicks on the child grid. The row should not get committed.
We have attached herewith a new test sample application with few more changes that we have made today. Also please find attached the video file showing the record being added to the grid collection even after the validation check fails.
Hi Rob,
Thank you for your prompt reply. We had initially added 'e.cancel = true' in the EditModeEnding method, however using this, the edit mode ending method is fired recursively.
Further, as you suggested, we added set the 'e.cancel =true', but as mentioned above after setting this property the message box is displayed recursively. We have attached herewith a video for you to replicate the issue.
Please let us know if there is any other way we can restrict the user from adding invalid values in the grid.
You are handling the perfect event for this. One of the event arguments for EditModeEnding is e.Cancel. If you set this property to true, focus will remain inside the editor and it will remain in edit mode. This should be what you are looking for. Whenever your validation fails, set e.Cancel to true and the cell will remain in edit mode.