This question is locked. New answers and comments are not allowed.
I have a RadGridView which is Dynamically Build with the help of
http://blogs.telerik.com/vladimirenchev/posts/11-09-28/dynamic-binding-for-your-silverlight-applications.aspx
http://www.telerik.com/forums/rowdetailstemplate-binding-with-dynamic-data
http://technobelities.blogspot.in/2013/03/dynamic-property-or-extended-property.html
My Xaml code is like this :
My View Model Loads RoutesGridData is an observable Collection which loaded Via Open RIA Domain Service. I also have ICommand EditGridRowCommand in my ViewModel.
I m not getting How I can get the Edited Data in my ViewModel. I tried in 2 way
1. By running Custom Commands for Add New Row / Update Row / The top 2 Button
http://demos.telerik.com/silverlight/#GridView/Commands
they works But I m not getting how I can capture this Edited / Added Data in ViewModel & can send to Open RIA Domain Service for making changes In db.
2. I Tried with EventTrigger for RowEditEnded but I m not getting latest Updated Data so I can process It.
Any Help?
Extra Request:
As you see My DataRow is of IDictionary which I build by Join of Few tables mapped in Linq. so Keys are the name of Column & Value is the data of that Property. Now These Database Column Name are dirty I want to change the Key with Display Names How to do?
http://blogs.telerik.com/vladimirenchev/posts/11-09-28/dynamic-binding-for-your-silverlight-applications.aspx
http://www.telerik.com/forums/rowdetailstemplate-binding-with-dynamic-data
http://technobelities.blogspot.in/2013/03/dynamic-property-or-extended-property.html
using System;using System.Collections.Generic;using System.ComponentModel;using System.Dynamic;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Ink;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using System.Linq;using Delasoft.Hpm.Infrastructure.Util.Const; namespace Delasoft.Hpm.Infrastructure.Models{ public class DataRow :DynamicObject , INotifyPropertyChanged { public IDictionary<string, object> data; private string DVL_URL = "http://delasoft.com"; public DataRow() { data=new Dictionary<string,object>(); } public DataRow(IDictionary<string, object> data) { var a = data["Routeid"]; string dvlUrl = ProjectConstant.DVL_URL + "BegMp=" + data["BegMp"].ToString() + "routeid=" + data["Routeid"].ToString(); data["Dvlurl"] = dvlUrl; this.data = data; this.data.OrderBy(x => x.Key); } public DataRow(IDictionary<string, object> data1,IDictionary<string, object> data2) { this.data = data1.Union(data2).ToDictionary(k => k.Key, v => v.Value); string dvlUrl = ProjectConstant.DVL_URL + "BegMp=" + data["BegMp"].ToString() + "routeid=" + data["Routeid"].ToString(); data["Dvlurl"] = dvlUrl; this.data.OrderBy(x => x.Key); } public DataRow(IDictionary<string, object> data1, IDictionary<string, object> data2, IDictionary<string, object> data3) { this.data = data1.Union(data2).ToDictionary(k => k.Key, v => v.Value).Union(data3).ToDictionary(k => k.Key, v => v.Value); string dvlUrl = ProjectConstant.DVL_URL + "BegMp=" + data["BegMp"].ToString() + "routeid=" + data["Routeid"].ToString(); data["Dvlurl"] = dvlUrl; this.data.OrderBy(x => x.Key); } public override IEnumerable<string> GetDynamicMemberNames() { //return base.GetDynamicMemberNames(); return data.Keys; } public override bool TryGetMember(GetMemberBinder binder, out object result) { //return base.TryGetMember(binder, out result); result= this[binder.Name]; return true; } public override bool TrySetMember(SetMemberBinder binder, object value) { //return base.TrySetMember(binder, value); this[binder.Name] = value; return true; } private void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public object this[string columnName] { get { if (data.ContainsKey(columnName)) { return data[columnName]; } return null; } set { if (!data.ContainsKey(columnName)) { data.Add(columnName, value); OnPropertyChanged(columnName); } else { if (data[columnName] != value) { data[columnName] = value; OnPropertyChanged(columnName); } } } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion }}My Xaml code is like this :
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal"> <telerik:RadButton Content="Save Edit / Update" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0" Command="telerikGrid:RadGridViewCommands.CommitEdit" CommandTarget="{Binding ElementName=DictRouteGridView}"/> <telerik:RadButton Content="Cancel Edit / Update" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0" Command="telerikGrid:RadGridViewCommands.CancelRowEdit" CommandTarget="{Binding ElementName=DictRouteGridView}" /><telerik:RadGridView Grid.Row="1" x:Name="DictRouteGridView" ItemsSource="{Binding RoutesGridData}" SelectionMode="Extended" IsSynchronizedWithCurrentItem="true" SelectedItem="{Binding SelectedDataRowsItem,Mode=TwoWay}" behaviour:RadGridSelectedItemsBindingBehavior.SelectedItems="{Binding SelectedDataRowsItems}"> <i:Interaction.Triggers> <i:EventTrigger EventName="RowEditEnded"> <i:InvokeCommandAction Command="{Binding EditGridRowCommand}" CommandParameter="{Binding ElementName=DictRouteGridView, Path=SelectedItem }"></i:InvokeCommandAction> </i:EventTrigger> </i:Interaction.Triggers> </telerik:RadGridView>My View Model Loads RoutesGridData is an observable Collection which loaded Via Open RIA Domain Service. I also have ICommand EditGridRowCommand in my ViewModel.
I m not getting How I can get the Edited Data in my ViewModel. I tried in 2 way
1. By running Custom Commands for Add New Row / Update Row / The top 2 Button
http://demos.telerik.com/silverlight/#GridView/Commands
they works But I m not getting how I can capture this Edited / Added Data in ViewModel & can send to Open RIA Domain Service for making changes In db.
2. I Tried with EventTrigger for RowEditEnded but I m not getting latest Updated Data so I can process It.
Any Help?
Extra Request:
As you see My DataRow is of IDictionary which I build by Join of Few tables mapped in Linq. so Keys are the name of Column & Value is the data of that Property. Now These Database Column Name are dirty I want to change the Key with Display Names How to do?