I'm binding a gridview to a DataTable whith 3 columns A,B,Total, where total is A+B.
When Cell A or B is changed I update the DataTable using a class that Notifies the propertychanged.
If I use the default DataGrid from WPF the column Total, is updated accordingly, but when I use the RagGridView, it's not updated. In order to have it updated I have to create a button and call the rebind method. (If I call the rebind whithin the CellEditEnded handler I get into an infitinte recursive loop; if I add a boolean to avoid this, I get exceptions...)
How would be the way to get this working ? Which means how to update Sum column if A or B has been modified, acknowledging the business logic is managed within the class generating/updating the DataTable.
Thanks for your answer.
private
void
gridView_CellEditEnded(
object
sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e)
{
if
(!e.OldData.Equals(e.NewData))
{
this
.DataProvider.Refresh();
}
}
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
this
.gridView.Rebind();
}
7 Answers, 1 is accepted
Have you tried binding to the DataView instead of the DataTable itself?
Looking forward to hearing from you!
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I tried using the DataView (actually I used the DataTable.DefaultView), but I'm getting an exception. Shall I log a defect ?
David.
System.ArgumentException occurred
Message=The type
'DataRowView' does not contain a public property named 'A'.
Parameter name: propertyName
Source=System.ComponentModel.DataAnnotations
ParamName=propertyName
StackTrace:
at System.ComponentModel.DataAnnotations.ValidationAttributeStore.TypeStoreItem.GetPropertyStoreItem(String propertyName)
at System.ComponentModel.DataAnnotations.ValidationAttributeStore.GetPropertyValidationAttributes(ValidationContext validationContext)
at System.ComponentModel.DataAnnotations.Validator.GetPropertyValues(Object instance, ValidationContext validationContext)
at System.ComponentModel.DataAnnotations.Validator.GetObjectPropertyValidationErrors(Object instance, ValidationContext validationContext, Boolean validateAllProperties, Boolean breakOnFirstError)
at System.ComponentModel.DataAnnotations.Validator.GetObjectValidationErrors(Object instance, ValidationContext validationContext, Boolean validateAllProperties, Boolean breakOnFirstError)
at System.ComponentModel.DataAnnotations.Validator.TryValidateObject(Object instance, ValidationContext validationContext, ICollection`1 validationResults, Boolean validateAllProperties)
at Telerik.Windows.Data.SafeValidator.TryValidateObject(Object instance, ValidationContext validationContext, ICollection`1 validationResults, Boolean validateAllProperties)
in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Data\Validation\SafeValidator.cs:line 18
InnerException:
May I ask you to open a support ticket and attach a sample project that demonstrates the issue there so we can debug it and see what goes wrong?
Thank you in advance!
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Please try setting RadGridView.ValidatesOnDataErrors to None.
Rossen Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
The type 'DataRowView' does not contain a public property named 'DataTableColumnName'. Parameter name: propertyName.
This column is the first in DataView. I've changes another column.
Well, we will then need a runnable sample project to see what exactly is going on, because we cannot guess from the information you have provided.
I suppose you are letting the grid auto-generate its columns.
Rossen Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.