Error not shown in xtragrid for custom property


Author
Message
Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I have created custom property and bind it to xtragrid.column. Error provider for this property doesnt be shown when I save data. It works for other property (mapped to data)

Any ideas?

Thank you

Replies
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Here's the code for the IDataErrorInfo.Item get:

                '-- Return the error for the given field
                If Me.BrokenRules.Contains(Me.CurrentRowIndex, columnName) Then
                    Return Me.BrokenRules(Me.CurrentRowIndex, columnName).Description
                ElseIf Me.CurrentDataTable.Columns.Contains(columnName) Then
                    Return Me.CurrentRow.GetColumnError(columnName)
                Else
                    Return String.Empty
                End If

So, if the BrokenRules collection has an entry for the current row and "ItemCode", then it will return the description in the broken rule.  Otherwise, it checks the underlying DataTable for errors, then just returns an empty string.  Since your custom field does not exist as a column, the second condition will never be hit, so you have to verify that the broken rule is being added properly.

You can use the ToArray() method on the BrokenRules to see all of the rules in the collection and make sure that you're rule is in there for the "ItemCode" property.

Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

How could I make control response to IDataErrorInfo for custom field?



Thank you
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
It will work if your custom field has a field within the DataTable in the BO.  If you have a custom property that does not pull from the internal data table of the BO then it will not return an error.  The same applies for the broken rule.  So at present, without having another object, you would have to add the field to the SELECT or manually to the data table using the Columns collection of the CurrentDatatable.  Once the field exists, then you can just add a broken rule:

Me.AddBrokenRule("MyCustomField", "My Error")

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Chan - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Chan - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Chan - 18 Years Ago
                         It is because the custom property is not set in error. For example,...
Trent L. Taylor - 18 Years Ago
                             Hi, How to accomplish this? Sorry, still new to .NET. Thank you
Chan - 18 Years Ago
                                 When the IDataErrorInfo interface returns the error for the specified...
StrataFrame Team - 18 Years Ago
                                     Hi, ((System.ComponentModel.IDataErrorInfo)this)["ItemCode"] return...
Chan - 18 Years Ago
                                         Here's the code for the IDataErrorInfo.Item get: '-- Return the...
StrataFrame Team - 18 Years Ago
                                             Hi,
How could I make control response to IDataErrorInfo for...
Chan - 18 Years Ago
                                                 It will work if your custom field has a field within the DataTable in...
Trent L. Taylor - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search