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

Set Time Interval for GridDateTimeColumn

7 Answers 441 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aniket Braganza
Top achievements
Rank 2
Aniket Braganza asked on 01 Aug 2008, 04:18 AM
I know how to set the Time interval for RadDateTimePicker to a value that I need, as well as the number of columns etc. My problems is that I do not know of any way of doing this for the GridDateTimeColumn, to ensure that my intervals for all my time pickers are consistent across my site.

How do I do this?

7 Answers, 1 is accepted

Sort by
0
Aniket Braganza
Top achievements
Rank 2
answered on 02 Aug 2008, 07:48 PM
Apparently no one has needed this functionality or no one can help me. I am assuming someone from Telerik would know the answer...
0
Konstantin Petkov
Telerik team
answered on 04 Aug 2008, 05:43 AM
Hi Aniket,

You can get the control for each item in ItemCreated or ItemDataBound (when the data is already respected) Grid events and change control's settings accordingly. See the help article here and the demo below for details:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/AccessingCellsAndRows/DefaultCS.aspx

Of course, you will need the GridDateTimeColumn's PickerType="RadDateTimePicker" setting added.

All the best,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Shinu
Top achievements
Rank 2
answered on 04 Aug 2008, 07:16 AM
Hi Aniket,

Try setting the Time interval for the RadDateTimePicker in the GridDateTimeColumn as shown below.

ASPX:
<telerik:GridDateTimeColumn  PickerType="DateTimePicker"  DataField="DateCol" DataType="System.DateTime" HeaderText="DateCol" 
                            SortExpression="DateCol" UniqueName="DateCol" ></telerik:GridDateTimeColumn> 
                         

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditableItem)&&(e.Item.IsInEditMode)) 
        { 
            GridEditableItem item = (GridEditableItem)e.Item; 
            RadDateTimePicker DatTimPkr = (RadDateTimePicker)item["DateCol"].Controls[0]; 
            DatTimPkr.TimeView.Interval = new TimeSpan(0, 15, 0); 
        } 
    } 

Thanks
Shinu.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 01 Jun 2010, 04:42 PM
any chance this has been changed in the latest versions of the radgrid so it can be set in the markup?
0
Chris
Top achievements
Rank 1
answered on 15 Dec 2010, 07:25 AM
I'm trying to set the interval to 15mins in the ItemDataBound event as suggested. I can see the interval set correctly in the debugger but the time picker is still showing the hourly interval. The grid is doing an inline edit if that matters.

protected void rgJobSchedule_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem item = (GridEditableItem)e.Item;
            RadTimePicker DatTimPkr = (RadTimePicker)item["StartTime"].Controls[0];
            DatTimPkr.TimeView.Interval = new TimeSpan(0, 15, 0);
        }
    }

Any ideas?

Thanks,
Chris
0
Bodevain Svensson
Top achievements
Rank 1
answered on 15 Dec 2010, 11:49 AM
See whether you assign the interval for the SharedTimeView will get what you want:

DatTimPkr.SharedTimeView.Interval = new TimeSpan(0, 15, 0);

I recall that the built-in datetime grid column uses shared calendar and timeview internally.

Bodevain

0
Chris
Top achievements
Rank 1
answered on 15 Dec 2010, 03:12 PM
That did the trick. Thanks!!!!!
Tags
Grid
Asked by
Aniket Braganza
Top achievements
Rank 2
Answers by
Aniket Braganza
Top achievements
Rank 2
Konstantin Petkov
Telerik team
Shinu
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Veteran
Iron
Chris
Top achievements
Rank 1
Bodevain Svensson
Top achievements
Rank 1
Share this question
or