This question is locked. New answers and comments are not allowed.
Hi everybody,
I don't get it... I use VS2010 and Silverlight 4 with Ria Services.
I use LinqToSql-DomainService's with my own classes.
I have a master-detail scenario. I have Products and ProductDatas
Every Product has a EntitySet of ProductDatas.
In my view, I can show the master and detail data. I also can insert/edit/delete Products. But I only can edit the ProductDatas. Insert and delete is not possible (from the RadGridView -> directly via DomainService, it works).
I also tried to set the "ShowInsertRow" property. The Row is displayed in my master and detail, but it only works in my master-grid. When I click this row on my detail-grid, nothing happend.
I post some code for a better understanding:
My class definitions on the server side:
The auto-generated code for the ProductDBItem on client side looks like this:
The XAML - Code of my master-detail view:
My Domainservice on server side:
I don't have a seperate DomainService for the ProductDataDBItem (because I include them in the ProductDBItem-Domainservice)
I hope thats all you need to understand my problem.
So. What can I do? Why can't I insert a row in the detail-grid with the "InsertRow"?
I don't get it... I use VS2010 and Silverlight 4 with Ria Services.
I use LinqToSql-DomainService's with my own classes.
I have a master-detail scenario. I have Products and ProductDatas
Every Product has a EntitySet of ProductDatas.
In my view, I can show the master and detail data. I also can insert/edit/delete Products. But I only can edit the ProductDatas. Insert and delete is not possible (from the RadGridView -> directly via DomainService, it works).
I also tried to set the "ShowInsertRow" property. The Row is displayed in my master and detail, but it only works in my master-grid. When I click this row on my detail-grid, nothing happend.
I post some code for a better understanding:
My class definitions on the server side:
| public class ProductDBItem |
| { |
| [Key] |
| public int ProductId { get; set; } |
| public string Productname { get; set; } |
| .... |
| private EntitySet<ProductDataDBItem> _ProductDatas; |
| [Include] |
| [Composition] |
| [AssociationAttribute("ProductDBItem_ProductDataDBItem","ProductId","ProductId")] |
| public EntitySet<ProductDataDBItem> ProductDatas |
| { |
| get |
| { |
| if (_ProductDatas == null) |
| _ProductDatas = new EntitySet<ProductDataDBItem>(); |
| return _ProductDatas; |
| } |
| set |
| { |
| _ProductDatas = value; |
| } |
| } |
| } |
| public class ProductDataDBItem |
| { |
| [Key] |
| public int ProductDataId { get; set; } |
| public int ProductId { get; set; } |
| public int LanguageId { get; set; } |
| ... |
| } |
The auto-generated code for the ProductDBItem on client side looks like this:
| public sealed partial class ProductDBItem : Entity |
| { |
| private EntityCollection<ProductDataDBItem> _productDatas; |
| private int _productId; |
| .... |
| #region Extensibility Method Definitions |
| /// <summary> |
| /// This method is invoked from the constructor once initialization is complete and |
| /// can be used for further object setup. |
| /// </summary> |
| partial void OnCreated(); |
| partial void OnProductIdChanging(int value); |
| partial void OnProductIdChanged(); |
| .... |
| #endregion |
| /// <summary> |
| /// Initializes a new instance of the <see cref="ProductDBItem"/> class. |
| /// </summary> |
| public ProductDBItem() |
| { |
| this.OnCreated(); |
| } |
| /// <summary> |
| /// Gets the collection of associated <see cref="ProductDataDBItem"/> entities. |
| /// </summary> |
| [Association("ProductDBItem_ProductDataDBItem", "ProductId", "ProductId")] |
| [Composition()] |
| public EntityCollection<ProductDataDBItem> ProductDatas |
| { |
| get |
| { |
| if ((this._productDatas == null)) |
| { |
| this._productDatas = new EntityCollection<ProductDataDBItem>(this, "ProductDatas", this.FilterProductDatas); |
| } |
| return this._productDatas; |
| } |
| } |
| /// <summary> |
| /// Gets or sets the 'ProductId' value. |
| /// </summary> |
| [DataMember()] |
| [Editable(false, AllowInitialValue=true)] |
| [Key()] |
| [RoundtripOriginal()] |
| public int ProductId |
| { |
| get |
| { |
| return this._productId; |
| } |
| set |
| { |
| if ((this._productId != value)) |
| { |
| this.OnProductIdChanging(value); |
| this.ValidateProperty("ProductId", value); |
| this._productId = value; |
| this.RaisePropertyChanged("ProductId"); |
| this.OnProductIdChanged(); |
| } |
| } |
| } |
| ... |
| private bool FilterProductDatas(ProductDataDBItem entity) |
| { |
| return (entity.ProductId == this.ProductId); |
| } |
| /// <summary> |
| /// Computes a value from the key fields that uniquely identifies this entity instance. |
| /// </summary> |
| /// <returns>An object instance that uniquely identifies this entity instance.</returns> |
| public override object GetIdentity() |
| { |
| return this._productId; |
| } |
| } |
The XAML - Code of my master-detail view:
| <riaControls:DomainDataSource |
| AutoLoad="True" |
| LoadedData="DomainDataSource_LoadedData" |
| x:Name="ProductDomainDataSourceOriginal" |
| QueryName="GetProductDBItemsQuery" |
| SubmittedChanges="ProductDomainDataSource_SubmittedChanges" |
| LoadingData="ProductDomainDataSourceOriginal_LoadingData"> |
| <riaControls:DomainDataSource.DomainContext> |
| <service:ProductContext /> |
| </riaControls:DomainDataSource.DomainContext> |
| <riaControls:DomainDataSource.QueryParameters> |
| <riaControls:Parameter ParameterName="languageId" Value="{Binding ElementName=languageSelectOriginal, Path=SelectedLanguageID}"/> |
| </riaControls:DomainDataSource.QueryParameters> |
| </riaControls:DomainDataSource> |
| ...... |
| <telerik:RadGridView AutoGenerateColumns="False" |
| HorizontalAlignment="Stretch" |
| Margin="0,70,0,0" |
| Name="grdProductOriginal" |
| VerticalAlignment="Stretch" |
| ItemsSource="{Binding ElementName=ProductDomainDataSourceOriginal, Path=Data}" |
| IsBusy="{Binding IsLoadingData, ElementName=ProductDomainDataSourceOriginal}" |
| RowLoaded="grdProductOriginal_RowLoaded" |
| Grid.Column="0" |
| RowEditEnded="grdProductOriginal_RowEditEnded" |
| ShowInsertRow="True"> |
| <telerik:RadGridView.Columns> |
| <telerik:GridViewToggleRowDetailsColumn /> |
| <telerik:GridViewDataColumn Header="Productname" DataMemberBinding="{Binding Productname, Mode=TwoWay}" Width="120"/> |
| <telerik:GridViewDataColumn Header="Maingroup" DataMemberBinding="{Binding GroupMainId, Mode=TwoWay}" Width="120"/> |
| <telerik:GridViewDataColumn Header="Subgroup" DataMemberBinding="{Binding GroupSubId, Mode=TwoWay}" Width="120"/> |
| <telerik:GridViewDataColumn Header="Pattern" DataMemberBinding="{Binding Pattern, Mode=TwoWay}" Width="120"/> |
| <telerik:GridViewDataColumn Header="Picture" DataMemberBinding="{Binding ImageId, Mode=TwoWay}" Width="120"/> |
| </telerik:RadGridView.Columns> |
| <telerik:RadGridView.RowDetailsTemplate> |
| <DataTemplate> |
| <telerik:RadTabControl BackgroundVisibility="Collapsed" x:Name="tabProductData" Margin="10" VerticalAlignment="Center" Background="Transparent"> |
| <telerik:RadTabItem Header="Daten" Margin="10,0,0,0" Height="24" Foreground="Black"> |
| <Grid> |
| <telerik:RadGridView Margin="0,5,0,0" |
| AutoGenerateColumns="false" |
| HorizontalAlignment="Stretch" |
| Name="grdProductDataOriginal" |
| VerticalAlignment="Stretch" |
| ItemsSource="{Binding ProductDatas, Mode=TwoWay}" |
| RowEditEnded="grdProductOriginal_RowEditEnded" |
| CanUserInsertRows="True" |
| CanUserDeleteRows="True" |
| ShowInsertRow="True"> |
| <telerik:RadGridView.Columns> |
| <telerik:GridViewDataColumn Header="Order-No." DataMemberBinding="{Binding OrderNo, Mode=TwoWay}" Width="100"/> |
| <telerik:GridViewDataColumn Header="Caption" DataMemberBinding="{Binding ProductDataCaption, Mode=TwoWay}" Width="150"/> |
| <telerik:GridViewDataColumn Header="Text" DataMemberBinding="{Binding ProductDataText}" Width="320"> |
| <telerik:GridViewDataColumn.CellEditTemplate> |
| <DataTemplate> |
| <TextBox Text="{Binding ProductDataText, Mode=TwoWay}" AcceptsReturn="True" KeyDown="TextBox_KeyDown"/> |
| </DataTemplate> |
| </telerik:GridViewDataColumn.CellEditTemplate> |
| </telerik:GridViewDataColumn> |
| </telerik:RadGridView.Columns> |
| </telerik:RadGridView> |
| </Grid> |
| </telerik:RadTabItem> |
| <telerik:RadTabItem Header="Vorschau" Margin="10,0,0,0" Height="24" Foreground="Black"> |
| </telerik:RadTabItem> |
| <telerik:RadTabItem Header="Menge" Margin="10,0,0,0" Height="24" Foreground="Black"> |
| </telerik:RadTabItem> |
| </telerik:RadTabControl> |
| </DataTemplate> |
| </telerik:RadGridView.RowDetailsTemplate> |
| </telerik:RadGridView> |
My Domainservice on server side:
| [RequiresAuthentication] |
| [EnableClientAccess()] |
| public class ProductService : LinqToSqlDomainService<ltsMainModelDataContext> |
| { |
| public IQueryable<ProductDBItem> GetProductDBItems(int languageId) |
| { |
| var result = new List<ProductDBItem>(); |
| .... |
| return result.AsQueryable(); |
| } |
| public void InsertProductDBItem(ProductDBItem item) |
| { |
| ... |
| } |
| public void UpdateProductDBItem(ProductDBItem item) |
| { |
| ... |
| } |
| public void DeleteProductDBItem(ProductDBItem item) |
| { |
| ... |
| } |
| } |
I don't have a seperate DomainService for the ProductDataDBItem (because I include them in the ProductDBItem-Domainservice)
I hope thats all you need to understand my problem.
So. What can I do? Why can't I insert a row in the detail-grid with the "InsertRow"?