Datepicker needs double click for manual entry

3 posts, 0 answers
  1. Gerry
    Gerry avatar
    17 posts
    Member since:
    Mar 2009

    Posted 24 Sep 2009 Link to this post

    I have a problem that I have not been able to solve.

    Because in a gridview we have different data types in the same column, we change the edit template as we go and have discovered that for the datepicker we have to click into it twice before a date can be manually entered. This is a nuisance for our customers, because they enter the data by tabbing through the fields and entering whatever type of data is necessary.

    I have prepared a sample below which shows the problem in the "Date" column of the grid. Because I'm setting the CellEditTemplate, the date picker acts differently. In order to enter a date in the "Date" column, you have to click on the cell, then you have to click once more to be eble to type in the date.

    Or if you tab through the "Date" column you always have to pick up the mouse again, click into the datepicker and only then can you manually type in the date.

    If I did not set the focus for the cell, you would have to click 3 times into the cell to be able to enter a date.

    But I'm still missing somethng. Can you help?

    Sample Code (Just try to enter dates in the "Date" column of the gridview).

    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.Collections.ObjectModel;
    using Telerik.Windows.Controls.GridView;
    using Telerik.Windows.Controls;

    namespace GerrySilverlight
        public partial class UCSimpleGrid : UserControl
            private ObservableCollection<SimpleRow> SimpleRowList = new ObservableCollection<SimpleRow>();
            private SimpleRow _currentRowRec = null;

            public UCSimpleGrid()

                SimpleRow trow1 = new SimpleRow();
                trow1.TRName = "Thomas";
                trow1.TRLohn = null;
                trow1.TRBG = 1000;
                trow1.TRZiv = 1;
                trow1.TRDate = DateTime.Now;
                trow1.TRInteger = 100;
                SimpleRow trow2 = new SimpleRow();
                trow2.TRName = "Rolf";
                trow2.TRLohn = 140000;
                trow2.TRBG = 500;
                trow2.TRZiv = 2;
                trow2.TRDate = null;
                trow2.TRInteger = 200;
                SimpleRow trow3 = new SimpleRow();
                trow3.TRName = "Marcel";
                trow3.TRLohn = 150000;
                trow3.TRBG = 1100;
                trow3.TRZiv = 3;
                trow3.TRDate = DateTime.Now;
                trow3.TRInteger = 300;
                SimpleRow trow4 = new SimpleRow();
                trow4.TRName = "Patricia";
                trow4.TRLohn = 160000;
                trow4.TRBG = 800;
                trow4.TRZiv = 4;
                trow4.TRDate = DateTime.Now;
                trow4.TRInteger = 400;
                SimpleRow trow5 = new SimpleRow();
                trow5.TRName = "Patricia";
                trow5.TRLohn = 150000;
                trow5.TRBG = 700;
                trow5.TRZiv = 5;
                trow5.TRDate = DateTime.Now;
                trow5.TRInteger = 500;

                UIRadGrid.ItemsSource = SimpleRowList;

            private void UIRadGrid_CurrentCellChanged(object sender, Telerik.Windows.Controls.GridViewCurrentCellChangedEventArgs evt)
                GridViewCell newCell = evt.NewCell;
                DataTemplate templa = LayoutRoot.Resources["UIDatePicker"] as DataTemplate;
                UIRadGrid.Columns[4].CellEditTemplate = templa;
                newCell.IsCurrent = true;
                newCell.IsInEditMode = true;
                RadDatePicker picky = templa.LoadContent() as RadDatePicker;
                if (picky != null)

            private void UIRadDatePicker_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
                SimpleRow rowrec = (sender as FrameworkElement).DataContext as SimpleRow;
                if (rowrec == null)
                    rowrec = _currentRowRec;
                if (rowrec != null)
                    rowrec.TRDate = (sender as RadDatePicker).SelectedDate;

            private void UIRadGrid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
                _currentRowRec = UIRadGrid.CurrentCell.ParentRow.DataContext as SimpleRow;

        public class SimpleRow
            public string TRName { get; set; }
            public System.Nullable<decimal> TRLohn { get; set; }
            public System.Nullable<decimal> TRBG { get; set; }
            public short TRZiv { get; set; }
            public System.Nullable<DateTime> TRDate { get; set; }
            public int TRInteger { get; set; }

    <UserControl x:Class="GerrySilverlight.UCSimpleGrid"
        <Grid x:Name="LayoutRoot" Background="White">
                <DataTemplate x:Key="UIDatePicker">
                    <input:RadDatePicker x:Name="UIRadDatePicker" SelectionChanged="UIRadDatePicker_SelectionChanged"/>
            <StackPanel Grid.Row="1" Orientation="Vertical">
                <TextBlock Text="Original Collection"/>
                <controls:RadGridView x:Name="UIRadGrid" MultipleSelect="False" ColumnsWidthMode="Auto" AutoGenerateColumns="False"
                                  CanUserFreezeColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False"
                                  ShowGroupPanel="False" IsFilteringAllowed="False" RowIndicatorVisibility="Collapsed"
                                  ShowColumnHeaders="True" ActionOnLostFocus="CommitEdit" Height="200" IsReadOnly="False"
                                  CurrentCellChanged="UIRadGrid_CurrentCellChanged" CellEditEnded="UIRadGrid_CellEditEnded">
                        <controls:GridViewDataColumn HeaderText="Name" DataMemberBinding="{Binding TRName}" IsReadOnly="True"/>
                        <controls:GridViewDataColumn HeaderText="Lohn" DataMemberBinding="{Binding TRLohn}" IsReadOnly="True"/>
                        <controls:GridViewDataColumn HeaderText="BG" DataMemberBinding="{Binding TRBG}" IsReadOnly="True"/>
                        <controls:GridViewDataColumn HeaderText="Zivilstand" DataMemberBinding="{Binding TRZiv}" IsReadOnly="True"/>
                        <controls:GridViewDataColumn HeaderText="Date" DataMemberBinding="{Binding TRDate, Mode=TwoWay}"/>
                        <controls:GridViewDataColumn HeaderText="Integer" DataMemberBinding="{Binding TRInteger}" IsReadOnly="True"/>

  2. Stefan Dobrev
    Stefan Dobrev avatar
    790 posts

    Posted 29 Sep 2009 Link to this post

    Hello Gerold,

    I was able to implement your request using the new property we have introduced in our latest internal build: EditTriggers on RadGridView. It allows you to specify conditions when RadGridView will start to edit a cell. Please find my updated project attached.

    All the best,
    Stefan Dobrev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Gerry
    Gerry avatar
    17 posts
    Member since:
    Mar 2009

    Posted 14 Oct 2009 Link to this post

    Thank you Stefan

    works great now. I had to get the latest build for the EditTriggers.
Back to Top