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

Documentation on GridDateTimeColumn

2 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
briankb
Top achievements
Rank 2
briankb asked on 21 Aug 2008, 03:44 PM
I'm trying to use the GridDateTimeColumn in a RADGrid vQ2 2008 Ajax.

I couldn't find any documentation.

Things I would like to do with it.
  • show date picker onClick
  • specify a default date (today) when the field is empty or when it is an insert
  • validation

2 Answers, 1 is accepted

Sort by
0
Leon
Top achievements
Rank 1
answered on 21 Aug 2008, 07:13 PM
Briankb,

A possible option would be to use the built-in Grid editors, GridDateTimeColumnEditor in this case. See the code-behind on the demo below which demonstrates dynamic validation through the Column editor in ItemCreated Grid event:

http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/Programming/WebGrid/DefaultCS.aspx

Note that you can also access the DatePicker through the Controls collection of the cell as well and set its default value or anything else.

Hope that helps!
~Leon
0
briankb
Top achievements
Rank 2
answered on 25 Oct 2008, 07:04 AM
I found the following code to push a date into the GridDateTimeColumn However I need it to only do so if the date is empty so I added the 5th line:

If dtpkr.SelectedDate.HasValue = False Then 

I'm using the following code.

    Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound 
        If (TypeOf e.Item Is GridEditableItem) AndAlso (e.Item.IsInEditMode) Then 
            Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem) 
            Dim dtpkr As RadDatePicker = DirectCast(item("ContentPublished").Controls(0), RadDatePicker) 
            If dtpkr.SelectedDate.HasValue = False Then 
                dtpkr.SelectedDate = DateTime.Today 
            End If 
 
            dtpkr.FocusedDate = DateTime.Today 
        End If 
    End Sub 

I added this reply for my own future reference. If there is a better way or you have additional comments please reply as well.
Tags
Grid
Asked by
briankb
Top achievements
Rank 2
Answers by
Leon
Top achievements
Rank 1
briankb
Top achievements
Rank 2
Share this question
or