I use RiaDomainDataSource for Get Data and In My User Control and i has 2 Containers DataGrid For Showing All Data and Details Grid has Controls For Manipulation Data
in My Case I work in Person User Control Which is has Columns : PersonID, PersonName, Age, CountryID which is Related to Country Table
in My Design i has ComboBox in Grid Details for Inserting Countries and Its Code Is :
<telerikInput:RadComboBox Grid.Column="1" Grid.Row="3" SelectedValuePath="CountryID" DisplayMemberPath="CountryName" ItemsSource="{Binding ElementName=CountryDomainDataSource, Path=Data}" SelectedValue="{Binding Path=CountryID, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" Margin="10" Name="cboCountry" Width="250">
And That is The Code for The Column Country In Data Grid
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Country.CountryName}" Header="Country" IsReadOnly="True"/>
:::::::::::::::::::::::::::The Probelm is when I select any Value from Country ComboBox to Insert it it doesn't Appear in DataGrid Column Immediatly .. It Appear Only If I Refresh The Page ... OR IF It Has Inserted Before in Data Grid.......... So How Can I Handle It:::::::::::::::::::::::::::::::
12 Answers, 1 is accepted
In order to be able to reproduce your exact scenario, I would need a bit more information about its exact settings. Is the RadComboBox used as a CellTemplate/ CellEditTemplate for a particular column ? Is the RadComboBox in the details and you want to update a value of its parent row - it is defined in the RowDetails and on selection changed to update a particular cell's value ? Please specify as much information on the topic as possible, so that I could reproduce your case.
Maya
the Telerik team
You need to set the SelectedValue property of the RadComboBox to the property of the of the grid source that you want to update. On the other hand, the SelectedValuePath should be set to the corresponding property in the RadComboBox ItemsSource.
I am sending you a sample project illustrating the proposed solution.
Maya
the Telerik team
First Thanks for Your Care
Second I think there is a misunderstanding I will Explain My Problem In Other And Clear Way I have A silverlight Page which is devided to 2 parts DataGridView just for Showing Data And Select Current Item and The Other is Panel ... The Data Grid View and The Panel are Seprated nut have the same RiaDomain Data Source .......... i Use Panel and Its Controls for Manpulating Data ............ for Example If I have Person(Name,Age) Table and It is Related with Country Table and I Have CountryID as Forign Key In Person Table ............. so and Data Grid View i will have 3 Grid View Data Column (Name, Age,CountryName) i will bind the First and Second Property Direct to data Grid View but The Third i will use Navigation Property in it Country.CountryName and In Bottom I have Panel which i use it for add and edit i have 3 controls in it Name TextBox, Age Text Box and Country Combo Box The Problem is Here...............................................................................................
when i add new object to RiaDomainDataSource and Start to Enter Data all Data Appear immediately in DataGrid View also .... Thats Mean when I write The Name for The Person in Panel Text Box it appear also at the same time in Name Data Grid View Column The Problem in Country Combo box when I select Value From Country Combo Box which in Panel The Value Doesn't Appear in Country Column in GridView at the same Time Expect I Refresh The Page or The Value is Inserted Before
It would be great if you could send a sample application so that I could see the implementation of your Business Objects and the exact settings of you controls. Basically, so far I may only guess about them and consequently I am not able to provide you with a specific and appropriate solution of your exact scenario.
Maya
the Telerik team
I Create That Example for My Case ... Look I Have 2 Tables in Data Base The First is Player and The Second is Club and Player Table has ClubID as A Foriegn Key and Have PlayerName, Age and Height Also so.......... I add My EDMX File And Domain Service Class And I Edit on It By Adding Include to Navigation Property to access it ........... I Created Player Page which is Devided as I descriped Before DataGridView Just for Showing Data and Panel has Some Controls for Data Manipulation and Both work with the same RiaDomainDataSource ............... I will Descrip Also All Attached Pics to Understand The Case
1-general case : In That Case I Select Row From RadDataGrid And The Data Are binded Automatic to Panel Controls (It Works Fine)
2-edit age : Here I am Trying to Edit in Data in Panel Controls And I try To Change Age For Eto'o From 29 to 30 when I Change it in Panel in Updated Automatic in RadDataGrid to 30 Before Pressing Save Button (It Works Fine)
3-edit exist inserted club : Here I am Trying to Change Club for Eto'o from Internazionale To Ajax and See That Ajax Club has Selected and Inserted Before in Row ID 67 For Luis Suarez so When I select Ajax It Appear Automatic in RadDataGrid For Samuel Eto'o(It Works Fine)
4-edit new inserted club : Here The Problem Appear I try to change Club for Eto'o to Roma which is not Inserted before for any Player so When I select It for Eto'o In RadDataGridView Row Appear with no any value even If I Press Save Only It Works when i Refresh The Page (The Problem)
5-add exist inserted club : Here I'm Trying To Add New Player so I write The Name, Age, Height and Select Club.. Look Internazionale Club has Inserted Before for Players so All Inserted Data Appear Automatic in RadDataGridView New Row Before Pressing Save (It Works Fine)
6-add new inserted club : Here I'm Trying To Add New Player as Pre Example but Here I'M Trying To Select New Club Not Insreted Before for Any Player so It Doesn't Appear Also In RadDataGridView New Row... All Data Appear but Club Not Appear Even If I Pressing Save Button Becasue I didn't Insert It Before for any Player (The Problem)
7-save new inserted club : Here After Pressing Save as I tell You Before all Data Appear but Club Still Not Appear It Will Apear If I Refresh The Page Only
<UserControl x:Class="TelerikTest.Views.Players" mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="700" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:my="clr-namespace:TelerikTest.Web.Models" xmlns:my1="clr-namespace:TelerikTest.Web.Services" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"> <Grid x:Name="LayoutRoot"> <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Player, CreateList=true}" Height="0" LoadedData="playerDomainDataSource_LoadedData" Name="playerDomainDataSource" QueryName="GetPlayersQuery" Width="0"> <riaControls:DomainDataSource.DomainContext> <my1:DomainServiceClass /> </riaControls:DomainDataSource.DomainContext> </riaControls:DomainDataSource> <Grid DataContext="{Binding ElementName=playerDomainDataSource, Path=Data}" HorizontalAlignment="Center" Margin="168,278,168,0" Name="grid1" VerticalAlignment="Top"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <sdk:Label Content="Player Name:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" Margin="10" VerticalAlignment="Center" /> <telerik:RadMaskedTextBox Grid.Column="1" Grid.Row="0" HorizontalAlignment="Center" Margin="10" Name="playerNameRadMaskedTextBox" Value="{Binding Path=PlayerName, Mode=TwoWay}" VerticalAlignment="Center" MaskType="None" MaskedText="" Width="250" /> <sdk:Label Content="Age:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" Margin="10" VerticalAlignment="Center" /> <telerik:RadMaskedTextBox Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" Margin="10" Name="ageRadMaskedTextBox" Value="{Binding Path=Age, Mode=TwoWay}" VerticalAlignment="Center" MaskType="None" MaskedText="" Mask="" Width="250" /> <sdk:Label Content="Height:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Center" Margin="10" VerticalAlignment="Center" /> <telerik:RadMaskedTextBox Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center" Margin="10" Name="heightRadMaskedTextBox" Value="{Binding Path=Height, Mode=TwoWay}" VerticalAlignment="Center" MaskType="None" MaskedText="" Width="250" /> <sdk:Label Content="Club:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Center" Margin="10" VerticalAlignment="Center" /> <telerik:RadComboBox DisplayMemberPath="ClubName" SelectedValuePath="ClubID" SelectedValue="{Binding Path=ClubID, Mode=TwoWay}" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Center" ItemsSource="{Binding ElementName=clubDomainDataSource, Path=Data}" Margin="10" Name="clubIDRadComboBox" VerticalAlignment="Center" Width="250"> </telerik:RadComboBox> <telerik:RadButton Content="Add New" Grid.Column="0" Grid.Row="4" Height="Auto" HorizontalAlignment="Center" Margin="10" Name="btnAddNew" VerticalAlignment="Center" Width="Auto" Click="btnAddNew_Click" /> <telerik:RadButton Content="Save" Grid.Column="1" Grid.Row="4" Height="Auto" HorizontalAlignment="Center" Margin="10" Name="btnSave" VerticalAlignment="Center" Width="Auto" Click="btnSave_Click" /> </Grid> <telerik:RadGridView AutoGenerateColumns="False" Width="600" Height="200" HorizontalAlignment="Center" ItemsSource="{Binding ElementName=playerDomainDataSource, Path=Data}" Margin="0,50,0,0" Name="playerRadGridView" VerticalAlignment="Top" IsFilteringAllowed="False" IsEnabled="True" CanUserDeleteRows="False" CanUserInsertRows="False" ShowColumnHeaders="True" ShowGroupPanel="False" ShowInsertRow="False"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header="ID" IsReadOnly="True" DataMemberBinding="{Binding PlayerID}"/> <telerik:GridViewDataColumn Header="Player Name" IsReadOnly="True" DataMemberBinding="{Binding PlayerName}"/> <telerik:GridViewDataColumn Header="Age" IsReadOnly="True" DataMemberBinding="{Binding Age}"/> <telerik:GridViewDataColumn Header="Height" IsReadOnly="True" DataMemberBinding="{Binding Height}"/> <telerik:GridViewDataColumn Header="Club" IsReadOnly="True" DataMemberBinding="{Binding Club.ClubName}"/> </telerik:RadGridView.Columns> </telerik:RadGridView> <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Club, CreateList=true}" Height="0" LoadedData="clubDomainDataSource_LoadedData" Name="clubDomainDataSource" QueryName="GetClubsQuery" Width="0"> <riaControls:DomainDataSource.DomainContext> <my1:DomainServiceClass /> </riaControls:DomainDataSource.DomainContext> </riaControls:DomainDataSource> <Grid.Background> <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5"> <GradientStop Color="#FFE2E2E2" Offset="0" /> <GradientStop Color="#FFC1D1FF" Offset="1" /> </LinearGradientBrush> </Grid.Background> </Grid> </UserControl> Players User Control .CS Code
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.ComponentModel; namespace TelerikTest.Views { public partial class Players : UserControl { public Players() { InitializeComponent(); } private void playerDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e) { if (e.HasError) { System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK); e.MarkErrorAsHandled(); } else { HandleTransaction(); } } private void clubDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e) { if (e.HasError) { System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK); e.MarkErrorAsHandled(); } } private void btnAddNew_Click(object sender, RoutedEventArgs e) { (playerDomainDataSource.DataView as IEditableCollectionView).AddNew(); } private void btnSave_Click(object sender, RoutedEventArgs e) { if ((playerDomainDataSource.DataView as IEditableCollectionView).IsAddingNew) { (playerDomainDataSource.DataView as IEditableCollectionView).CommitNew(); } else { (playerDomainDataSource.DataView as IEditableCollectionView).CommitEdit(); } playerDomainDataSource.SubmitChanges(); } private void HandleTransaction() { if (playerDomainDataSource.DataView.Count == 0) { (playerDomainDataSource.DataView as IEditableCollectionView).AddNew(); } } } } Thanks Maya and Waiting Your Help
I was not able to reproduce the issue you defined. Please take a look at the sample project I used for testing the case and let me know if there is some misunderstanding according to your requirements.
All the best,Maya
the Telerik team