Welcome to the Xceed Community | Help
Community Search  

How do I use Datarow.RowError on Xceed grid?

Sort Posts: Previous Next
  •  10-07-2008, 8:12 AM Post no. 15938

    How do I use Datarow.RowError on Xceed grid?

    Good day.

    I bind a Xceed grid to a plain old System.Data.DataTable. 

    If I chage a row to have a error (either via row.RowError = "Bla!" or row.SetColumnError("SOME_COLUMN", "Bla!")) the DataTable is in error state, the DataSet is in error state, but the Xceed grid is not doing anything.

    How do I get the Xceed grid to update and reflect these errors?

    If I try to add a newrow using the Xceed insertionrow edit area and I input invalid data the grid does show the cute red exclimation mark and the tooltip tells me what is wrong.

    Thank you for your time :-)

  •  10-09-2008, 9:56 AM Post no. 15988 in reply to 15938

    Re: How do I use Datarow.RowError on Xceed grid?

    Hi,

    The Xceed.Wpf.DataGrid.Row's ValidationError property is set when there is an exception being thrown in the IEditableObject's EndEdit implementation.

    The cell's ValidationError property is set when the cell's CellValidationRules or its Content binding's ValidationRules returns an invalid validation result.

    By default, the content binding's ValidationRules are set to ExceptionValidationRule and DataErrorValidationRule.

    Under the hood, we subscribe to each of the cell's content binding's ValidaitonError and TargetUpdated event.  We are able to update the Cell's ValidationError property in these events.

    On the other hand, there is no way I know to detect a "row level" error on the object other that what we are currently doing (catching exceptions when we try to leave the edit process on the row).

    I think that this might be addressed by the ItemsControl's ItemBindingGroup property using the new BindingGroup concept which was introduced in .NET 3.5 Service Pack 1, however since we cannot target a specific service pack when compiling, we cannot currently implement its support in our product.

    For the time being, there is no way to make a row which is not leaving edit to react to a source error other than if one of its cells Content Binding is re-evaluated and becomes invalid through one of its binding ValidationRules.


    Regards,


    Pierre-Luc Ledoux
    Software Developer
    Xceed Software Inc.
  •  10-21-2008, 9:42 AM Post no. 16285 in reply to 15988

    Re: How do I use Datarow.RowError on Xceed grid?

    Hi Pierre-Luc.

    Thanks for the reply.

    Do you have any suggestions as to how I can proceed with this problem? We pass our datatable to some external logic that does manipulation and validation and potentially thousands of rows can be in error state. We do not always have a user editing the rows manually. We load a lot of data and process it, then display the result to the user. The user can then discard the data or try to fix the errors. At the moment we have to pop up a message box to inform the user that the data has errors.

    Is there any way that I can get the datagrid to display these errors? If not is it possible to bring out a solution in your next service pack?

    Here is a little information about row error states: https://ads.jiwire.com/JOS.aspx?http/msdn.microsoft.com/en-us/library/k3877412(VS.71).aspx

    Thank you

  •  10-21-2008, 12:38 PM Post no. 16297 in reply to 16285

    Re: How do I use Datarow.RowError on Xceed grid?

    Hi,

    The problem is two fold.

    The DataGridControl does support the IDataErrorInfo interface, which the DataRowView's implementation checks its underlying System.Data.DataRow for a column error.

    However, the Cell's DataContext and therefore the source of the cell's Content Binding is the System.Data.DataRow, which does not implement the IDataErrorInfo interface.

    Why the source is directly the System.Data.DataRow and not the DataRowView ?  Well, that's actually our making when binding through our DataGridCollectionView.

    You see, a DataView's DataRowViews are reycled and can therefore point to a different underlying System.Data.DataRow as time changes.  As you can imagine, this caused us many headaches for restoring the CurrentItem, SelectedItems and many other intricate details I won't plunge into.

    This morning, I investigated if we could reach a workaround in our validation code to directly interrogate the System.Data.DataRow's GetColumnError method when comes the time to validate the cell/row or when the cell's content changes from the source.

    As of now, there might or might not be a valid workaround.  But as far as I can see, it would be far from complete as setting a System.Data.DataRow's error through the SetColumnError method does not seem to notify the source that the item has changed. 

    This concretely means that there seems to be no way for us to actually know that the user has manually changed the System.Data.DataRow's error state and trigger the workaround I was investigating.

    I will log a feature request to be able to reflect the error states of System.Data.DataRow objects.

    Sadly though, I wouldn't hold my breath for it to be implemented since what I found up to now is sketchy on its own and since there does not seem any way for us to be notified of a change of error state.

    The only thing I could recommend in the meantime would be to use a IBindingList as a source and implement IDataErrorInfo on the business object as shown in our ValidationSample, on the ComposerEditable and ComposersBindingListComplete classes.

    I understand that depending on your actual situation, not using a DataView might not be an option, however that's the only solution I see at the moment.


    Regards,


    Pierre-Luc Ledoux
    Software Developer
    Xceed Software Inc.
  •  10-22-2008, 2:08 AM Post no. 16313 in reply to 16297

    Re: How do I use Datarow.RowError on Xceed grid?

    Hi Pierre-Luc.

    Thank you very much for your time and effort.

    Unfortunately using an IBindingList is not an option for me. What would work for me is if there is a way to tell the DataGrid to go run through all the rows and check for row errors. I do not have access to the Xceed grid plumbing so unfortunately you will need to help me with this :-)

    So rather than only rely on events, give the developer a way to tell the grid to go recheck the datasource for errors. I think this will be a very useful feature for other users as well.

    Thank you :-)

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.