Hello Telerik,
I'm using a DataTable to set my RadGridView ItemsSource. My grid was set like this :
_Xaml
<telerik:RadGridView x:Name="gridSaisie" Grid.Row="1" HorizontalAlignment="Stretch" Margin="5" ShowGroupPanel="False" CanUserInsertRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" CellValidating="gridSaisie_CellValidating" CellEditEnded="gridSaisie_CellEditEnded" RowEditEnded="gridSaisie_RowEditEnded"/>_C#
private void ConstructGrid() { //Création de la colonne de dates GridViewDataColumn colonneDate = new GridViewDataColumn(); colonneDate.DataMemberBinding = new Binding("Date"); colonneDate.Header = "Jour"; colonneDate.UniqueName = "Jour"; colonneDate.DataFormatString = "{0: dd}"; colonneDate.IsReadOnly = true; colonneDate.Width = 150; colonneDate.IsSortable = false; colonneDate.IsFilterable = false; colonneDate.HeaderTextAlignment = TextAlignment.Center; //colonneDate.DataType = typeof(DateTime); this.gridSaisie.Columns.Add(colonneDate); //Création dynamique des colonnes foreach (Variable v in this.ViewModel.Variables) { GridViewDataColumn colonneVariable = new GridViewDataColumn(); var bindVariable = new Binding(string.Format("Variable_{0}", v.Id)); bindVariable.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; bindVariable.StringFormat = "{0:F1}"; bindVariable.Mode = BindingMode.TwoWay; colonneVariable.DataMemberBinding = bindVariable; colonneVariable.Header = v.Code; colonneVariable.UniqueName = string.Format("Variable_{0}", v.Id); colonneVariable.IsReadOnly = false; //colonneVariable.Width = ; colonneVariable.IsSortable = false; colonneVariable.IsFilterable = false; colonneVariable.HeaderTextAlignment = TextAlignment.Center; //colonneVariable.DataType = typeof(double); this.gridSaisie.Columns.Add(colonneVariable); } } private void LoadData(int idStation) { this.gridSaisie.ItemsSource = this.ViewModel.Jours; //Its the DataTable
}
I have somes problems :
1) When I set DataType = typeof(...), the displayed values are empty.
2) StringFormat for the Date doesn't work.
3) When I start updating, the cell value is hidden (I think is linq to '4)')
3) I can't update values in the Grid. I found this topic : http://www.telerik.com/forums/updating-a-datatable-with-radgridview where is it explain that the update will be to do manually. So I didi it :
private void gridSaisie_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e) { int numCol = e.Cell.Column.DisplayIndex; int numRow = this.gridSaisie.Items.IndexOf(this.gridSaisie.SelectedItem); var row = this.ViewModel.Jours.Rows[numRow]; row.BeginEdit(); var colonnes = row.ItemArray; colonnes[numCol] = e.NewData.ToString();// Convert.ToDouble(e.NewData.ToString()); row.EndEdit(); row.AcceptChanges(); //this.gridSaisie.Rebind(); }But there isn't changement.
Can you help me ?
Thank you.
