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

Calculate and change time difference in side the Grid

1 Answer 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sathish venkat
Top achievements
Rank 2
sathish venkat asked on 19 May 2011, 01:40 PM
Hi,

    i am using Rad grid and in side i am binding three columns (Start time,End time and Time Difference)
inside the Start time and End time columns i am using Rad Time Picker controls. and inside the Time difference column i am using label control . my question is when i am chaging time(start time or end time) i need to update the time difference in client side.
can you please tell me the solution for this

if possible send me a sample please

FYI: i have attached my grid screen shot please verify

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 May 2011, 03:00 PM
Hello Sathish,

You can attach the client event OnDateChanged to the TimePicker and pass the Client ID of the Label and the RadTimePicker. Then from clent side access the controls, calculate the time difference and set the label value from there.
Here is a sample code:
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridEditFormItem && e.Item.IsInEditMode)//edit mode is editform/popup
       {
           GridEditFormItem item = (GridEditFormItem)e.Item;
          RadTimePicker pkr=(RadTimePicker)item.FindControl("RadTimePicker1");
          RadTimePicker pkr2 = (RadTimePicker)item.FindControl("RadTimePicker2");
          Label lbl = (Label)item.FindControl("Label1");
          pkr.ClientEvents.OnDateSelected = "function (button,args){OnDateSelected('" + pkr.ClientID + "','" + pkr2.ClientID + "','"+lbl.ClientID+"');}";
          pkr2.ClientEvents.OnDateSelected = "function (button,args){OnDateSelected('" + pkr.ClientID + "','" + pkr2.ClientID + "','" + lbl.ClientID + "');}";
       }
   }

Javascript:
function OnDateSelected(pkr1, pkr2, lbl)
    {
    // access the control and set the label value
   }

You can find more on RadTimePicker client side API from here.
RadTimePicker Client Object.

Thanks,
Shinu.
Tags
Grid
Asked by
sathish venkat
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or