Hi,
In one of my projects,I use WCF data services for querying the database,and use GridView, and DataForm for viewing and editing data.When the user double click on a row, I create a filtered DataServiceQuery (e.g. ID=55) and use it to initialize a QueryableDataServiceCollectionView<T> which I then assign to the RadDataForm ItemsSource.I can successfully add ,delete, and edit records by calling SubmitChanges() on the ItemsSource (which is of type QueryableDataServiceCollectionView<T>),
but I am facing other difficulties:
1-I have an entity Sim which has a 1 to many association property called Installations. When clicking Cancel while editing or inserting in the DataForm, I get the following error which seems to be caused by the DataForm trying to set a value on the Installations property.
Setting an instance of DataServiceCollection to an entity property is disallowed if the instance is already being tracked. Error occurred on property 'Installations' for entity type 'TDS.DeviceManagementDataService.Sim'.
2-When I open an existing record for editing,and click the 'insert' button,fill-in the form,and click save,the record is saved but the form goes back and display the record that was being edited earlier.
My last question is: what is the best way of databinding a RadDataForm when working with WCF data service ?
GridView Double Click Code:
SimView Window:
Thanks in advance
Madani
In one of my projects,I use WCF data services for querying the database,and use GridView, and DataForm for viewing and editing data.When the user double click on a row, I create a filtered DataServiceQuery (e.g. ID=55) and use it to initialize a QueryableDataServiceCollectionView<T> which I then assign to the RadDataForm ItemsSource.I can successfully add ,delete, and edit records by calling SubmitChanges() on the ItemsSource (which is of type QueryableDataServiceCollectionView<T>),
but I am facing other difficulties:
1-I have an entity Sim which has a 1 to many association property called Installations. When clicking Cancel while editing or inserting in the DataForm, I get the following error which seems to be caused by the DataForm trying to set a value on the Installations property.
Setting an instance of DataServiceCollection to an entity property is disallowed if the instance is already being tracked. Error occurred on property 'Installations' for entity type 'TDS.DeviceManagementDataService.Sim'.
2-When I open an existing record for editing,and click the 'insert' button,fill-in the form,and click save,the record is saved but the form goes back and display the record that was being edited earlier.
My last question is: what is the best way of databinding a RadDataForm when working with WCF data service ?
GridView Double Click Code:
private
void
SimsGridView_MouseDoubleClick(
object
sender, MouseButtonEventArgs e)
{
SimView view =
new
SimView();
QueryableDataServiceCollectionView<Sim> dataContext =
new
Telerik.Windows.Data.QueryableDataServiceCollectionView<Sim>(db, db.Sims.Where(i => i.ID == SimsGridView.GetSelectedItem<Sim>().ID).ToDataServiceQuery<Sim>());
dataContext.PageSize = 100;
dataContext.AutoLoad =
true
;
view.DataContext = dataContext;
view.Show();
view.Focus();
}
SimView Window:
<
telerik:RadDataForm
x:Name
=
"rdfSim"
ItemsSource
=
"{Binding}"
AutoGenerateFields
=
"False"
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Stretch"
ReadOnlyTemplate
=
"{StaticResource MyTemplate}"
NewItemTemplate
=
"{StaticResource MyTemplate}"
EditTemplate
=
"{StaticResource MyTemplate}"
EditEnded
=
"rdfSim_EditEnded"
CommandButtonsVisibility
=
"All"
ValidatingItem
=
"rdfSim_ValidatingItem"
DeletedItem
=
"rdfSim_DeletedItem"
>
</
telerik:RadDataForm
>
Thanks in advance
Madani