I want to Edit values in a certain column in a datagrid, and then update the datasource that's attached or assign to the xamldatagrid. However, I want to keep the all the remaining columns readonly. Here is a small project you can edit to show me how to edit a specific column in the xamldatagrid and save back changes back to the datasource. We actually can create column that has button in row cells to save row back to datasource.
Please review and modify attachment.
Hello pianoboy11,
I have been looking into your post.
Currently the best approach, that I can suggest is implementing the INotifyPropertyChanged Interface.
Please do not hesitate to let me know if you have any further questions on this matter.
Is there away to do it without implementing, the exist architecture, they are not using the normal wpf setup, which makes it harder for. However If I can't get that to work, I will just setup the InotifyPropertyChanged
In order for the collection, that is bound as a DataSource of the XamDataGrid I would suggest implementing the INotifyPropertyChanged Interface. This way when you edit a cell or add a new record the collection would be updated. More about this interface you can find in the following article: https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx .
If you would like to update a database I would suggest taking a look at the following blog post: http://es.infragistics.com/community/blogs/kiril_matev/archive/2011/02/25/implementing-crud-in-the-infragistics-xamdatagrid.aspx.
So I am assuming we would have to subcribe the other 4 grids I didnt create in xaml and do the same thing. I have one main grid in the xaml and then I have other grids created dynamically in code. The name of the field is call hours.
Question, after I have edit the values, how to bind back to the datasource or save values back to the underline grid datasource or datatable i am using.
Thank you for contacting us.
I have been looking into your post and into the provided sample application. As the Fields of the XamDataGrid are autogenerated I would suggest setting the AllowEdit property in the FieldSettings of the XamDataGrid to false. Here is a code example:
<igWPF:XamDataGrid.FieldSettings>
<igWPF:FieldSettings AllowRecordFiltering="True" AllowEdit="False" />
</igWPF:XamDataGrid.FieldSettings>
Then you can handle the loaded event of the XamDataGrid and in the handler of the event you can get the Field you want to be editable and change its FieldSettings as follows:
private void dataGrid_Loaded(object sender, RoutedEventArgs e)
{
(sender as XamDataGrid).FieldLayouts[0].Fields[0].Settings = new FieldSettings();
(sender as XamDataGrid).FieldLayouts[0].Fields[0].Settings.AllowEdit = true;
}
In the above code snippet I am getting the first Field of the XamDataGrid using its index(Field[0]). The if you know the name of the Field you can use it to find the Field too.