This is a migrated thread and some comments may be shown as answers.

Custom column not getting the new cell value

2 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alon Agmon
Top achievements
Rank 1
Alon Agmon asked on 29 May 2010, 10:52 PM
Hi,
I have a simple custom cell with a button and a text box
this is the code of the custom control , that will be used in edit mode
public static readonly DependencyProperty SelectedTextProperty = 
            DependencyProperty.Register("SelectedText"typeof(String), typeof(AsteaButtonFieldCtl), 
            new PropertyMetadata(null, OnSelectedTextChanged)); 
 
        public AsteaButtonFieldCtl() 
        { 
            InitializeComponent(); 
        } 
 
        public String SelectedText 
        { 
            get { return (String) this.GetValue(SelectedTextProperty); } 
            set { this.SetValue(SelectedTextProperty, value); } 
        } 
 
        
        private static void OnSelectedTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
        { 
            var ctl = (AsteaButtonFieldCtl)d; 
            ctl.NewTextUpdate((string)e.NewValue); 
        } 
 
        private void NewTextUpdate(string newText) 
        { 
            this.txt.Text = newText; 
        } 
 
        private void btn_Click(object sender, RoutedEventArgs e) 
        { 
            //nothing right now 
        } 
         
        private void txt_TextChanged(object sender, TextChangedEventArgs e) 
        { 
            this.SelectedText = txt.Text; 
        } 

BTW - while debugging this, events are called the values are being updated correctly
this user control is bound to a column

 public override FrameworkElement CreateCellEditElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem) 
        { 
            var lookupCtl = new AsteaButtonFieldCtl(); 
            lookupCtl.SetBinding(AsteaButtonFieldCtl.SelectedTextProperty, this.CreateValueBinding()); 
            return lookupCtl; 
        } 
        private Binding CreateValueBinding() 
        { 
            var valueBinding = new Binding(); 
            valueBinding.Mode = BindingMode.TwoWay; 
 
            valueBinding.NotifyOnValidationError = true
            valueBinding.ValidatesOnExceptions = true
            valueBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit; 
            valueBinding.Path = new PropertyPath(this.DataMemberBinding.Path.Path); 
            return valueBinding; 
        } 

Now... the problem!

everything is displayed correctly , but, after i finish editing the column data ,
i have a CellEditEnded event for post processing the values
and in that event
e.OldData // get the old value correctly
 e.NewData // this is null !!

any idea how to resolve this .. ?

Alon
(using the SL 2010 version)
string oldValue = .ToString();

2 Answers, 1 is accepted

Sort by
0
Alon Agmon
Top achievements
Rank 1
answered on 31 May 2010, 09:34 AM
any idea..?
0
Nedyalko Nikolov
Telerik team
answered on 03 Jun 2010, 08:30 AM
Hi Alon Agmon,

Sorry for the late answer. You should also override Column.GetNewValueFromEditor() method and its returned value will be passed to the CellEditEndedEventArgs.NewValue property. I hope this will help.

Greetings,
Nedyalko Nikolov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Alon Agmon
Top achievements
Rank 1
Answers by
Alon Agmon
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or