This is a migrated thread and some comments may be shown as answers.

Bind telerik Grid view to DataTable

7 Answers 200 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 10 Oct 2012, 07:22 AM
Hello,

   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

Sort by
0
Nick
Telerik team
answered on 11 Oct 2012, 01:38 PM
Hi David,

Have you tried binding to the DataView instead of the DataTable itself?

Looking forward to hearing from you!  

Kind regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
David
Top achievements
Rank 1
answered on 11 Oct 2012, 04:00 PM
Hi Thank for your answer.

  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:

0
Nick
Telerik team
answered on 12 Oct 2012, 11:53 AM
Hello David,

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! 

Regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Anton
Top achievements
Rank 1
answered on 22 Apr 2013, 12:26 PM
Any suggestions? I have the same problem.
0
Rossen Hristov
Telerik team
answered on 22 Apr 2013, 12:46 PM
Hi,

 
Please try setting RadGridView.ValidatesOnDataErrors to None.

All the best,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Anton
Top achievements
Rank 1
answered on 22 Apr 2013, 12:59 PM
"RadGridView.ValidatesOnDataErrors to None" - doesn't help.

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.
0
Rossen Hristov
Telerik team
answered on 22 Apr 2013, 01:25 PM
Hello,

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.

Regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Nick
Telerik team
David
Top achievements
Rank 1
Anton
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or