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

[Solved] Error on GridView when focus lost

3 Answers 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Siddhant
Top achievements
Rank 1
Siddhant asked on 21 Jan 2013, 02:08 PM
I have a RadGridView in which i have a custom CellEdit, The issue that I am facing is that when I am in the edit mode and if i click on a button or any other control it throws and error.
Have attached the error in the attachment

can anyone tell me on how to solve this issue an why is it coming

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 21 Jan 2013, 02:41 PM
Hi,

May I ask you to share a little bit more details on what is your "Custom CellEdit"? Do you reproduce the issue with the latest binaries? 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Siddhant
Top achievements
Rank 1
answered on 21 Jan 2013, 02:56 PM
Yes I am using the latest Binaries

the custom cell editor is

It works fine when i press enter or the row ends but when the edit is still in progress and i click on another control it give the error
DataTemplate _dt = (DataTemplate)XamlReader.Load(
                    @"<DataTemplate
                xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" xmlns:local=""clr-namespace:Cognizant.Ace.Pmo.Silverlight"">
 
                <TextBox Text=""{Binding period,Converter={StaticResource GridEditFormatter},ConverterParameter='" +  _dayBE.date + @"',Mode=TwoWay}""/>
              </DataTemplate>"
                    );
                gvdc.CellEditTemplate = _dt;
 
 
//Convertor is as follows-----------------------
public class GridEditFormatter : IValueConverter
    {
        private ObservableCollection<DayBE> _daysBE;
 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            _daysBE = value as ObservableCollection<DayBE>;
            if (_daysBE.SingleOrDefault(x => x.date == System.Convert.ToDateTime(parameter.ToString()))!=null)
            {
                return _daysBE.SingleOrDefault(x => x.date == System.Convert.ToDateTime(parameter.ToString())).allocation;
            }
            return 0;
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DayBE _editedDay = new DayBE();
            _editedDay.date = System.Convert.ToDateTime(parameter.ToString());
            _editedDay.allocation = System.Convert.ToDouble(value);
 
            if (_daysBE.SingleOrDefault(x => x.date == _editedDay.date) != null)
                _daysBE.Remove(_daysBE.Single(x => x.date == _editedDay.date));
             
            _daysBE.Add(_editedDay);
            return _daysBE;
        }
    }
0
Dimitrina
Telerik team
answered on 21 Jan 2013, 03:32 PM
Hello,

Will it be possible for you to send a simple runnable project demonstrating it so we can debug it locally to check what happens? You can take a look at this blog post for a reference on how to isolate a problem in a sample project.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Siddhant
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Siddhant
Top achievements
Rank 1
Share this question
or