Bind telerik Grid view to DataTable

8 posts, 0 answers
  1. David
    David avatar
    2 posts
    Member since:
    Jun 2012

    Posted 10 Oct 2012 Link to this post

    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();
           }



      
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 11 Oct 2012 Link to this post

    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.

  3. David
    David avatar
    2 posts
    Member since:
    Jun 2012

    Posted 11 Oct 2012 Link to this post

    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:

  4. Nick
    Admin
    Nick avatar
    593 posts

    Posted 12 Oct 2012 Link to this post

    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.

  5. Anton
    Anton avatar
    12 posts
    Member since:
    Sep 2012

    Posted 22 Apr 2013 Link to this post

    Any suggestions? I have the same problem.
  6. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Apr 2013 Link to this post

    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.

  7. Anton
    Anton avatar
    12 posts
    Member since:
    Sep 2012

    Posted 22 Apr 2013 Link to this post

    "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.
  8. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Apr 2013 Link to this post

    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.

Back to Top