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

about GridDateTimeColumn

4 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
xiaofeng
Top achievements
Rank 1
xiaofeng asked on 25 Aug 2008, 05:30 AM

hello
        I use GridDateTimeColumn in radgrid.Now ,I want do do something when I change the datetime of a cell.How I can do it ?did you have an evet?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Aug 2008, 07:33 AM
Hi,

Try accessing RadDatePicker for the GridDateTimeColumn in the edit mode and set its AutoPostBack property to true. Also add the SelectedDateChanged event handler in the code behind so that it will be fired when the date is changed.

ASPX:
  <telerik:GridDateTimeColumn UniqueName="DateCol" DataField="Date" HeaderText="DateCol" ></telerik:GridDateTimeColumn> 
             

CS:
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditableItem edititem = (GridEditableItem)e.Item; 
            RadDatePicker dtpkr = (RadDatePicker)edititem["DateCol"].Controls[0]; 
            dtpkr.AutoPostBack = true
            dtpkr.SelectedDateChanged += new Telerik.Web.UI.Calendar.SelectedDateChangedEventHandler(dtmpkr_SelectedDateChanged); 
        } 
    } 
    void dtmpkr_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e) 
    { 
 
    } 


Thanks
Shinu.
0
xiaofeng
Top achievements
Rank 1
answered on 26 Aug 2008, 12:54 AM
do you have client event,or other method without postback?
Thanks .Another thing,how can get the row index when it is in edit mode,it can not cause the rowselected event in mode?
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2008, 04:29 AM
Hi,

Try accessing the RadDatePicker for the GridDateTimeColumn on the server side and set the OnDateSelected client side event handler that is excecuted when ever the selected date is changed in the DatePicker.

CS:
  protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditableItem edititem = (GridEditableItem)e.Item; 
            RadDatePicker dtmpkr = (RadDatePicker)edititem["DateCol"].Controls[0]; 
            dtmpkr.ClientEvents.OnDateSelected = "OnDateSelected"
        } 
    } 


JS:
 <script type="text/javascript" language="javascript" > 
         function OnDateSelected() 
          { 
           alert('DateSelected') 
          } 
         
        </script> 


Thanks
Shinu
0
xiaofeng
Top achievements
Rank 1
answered on 27 Aug 2008, 02:49 AM
Thanks
Tags
Grid
Asked by
xiaofeng
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
xiaofeng
Top achievements
Rank 1
Share this question
or