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

RadTimePicker in RadGrid problem

1 Answer 82 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 06 Jan 2009, 09:27 PM

Hello,

I am using a RadTimePicker template column in a radgrid (both are RadControls for ASP.NET Q2 2008). I initialized StartTime and EndTime for the time pickers, but it does not take effect in the client side - the picker still displays time range from 12:00AM to 23:30. Here is the ASP page (there is only one radgrid control on the page):

<rad:radgrid id="gdActivityTime" runat="server" skin="Office2007" Autogeneratecolumns="false" width="95%">

         <MasterTableView DataKeyNames="ActivityNodeID" ShowHeader="false">
         <Columns>

        <rad:GridBoundColumn DataField="ActivityName" HeaderText="Activity"></rad:GridBoundColumn>

        <rad:GridTemplateColumn>

            <ItemTemplate>
                   <rad:RadTimePicker AutoPostBack="true" ID="pkDesignatedStartTime" runat="server" Width="85px" >
                       <TimeView ID="TimeView1" runat="server"  Skin="" Interval="0:30">
                       </TimeView>
                       <PopupButton Visible="False" />
                       <DatePopupButton Visible="False" />
                       <DateInput Skin="" />
                  </rad:RadTimePicker>
           </ItemTemplate>
       </rad:GridTemplateColumn>
    </Columns>
 
</MasterTableView>
</rad:radgrid>

Here is the code behind:

//generate 10 rows:
DataTable tblActTime = new DataTable();
tblActTime.Columns.Add(new DataColumn("ActivityName", typeof(string)));
tblActTime.Columns.Add(new DataColumn("DesignatedStartTime", typeof(TimeSpan)));
tblActTime.Columns.Add(new DataColumn("ActivityNodeID", typeof(string)));

for(int n=0; n<10; n++)
{
   DataRow dract = tblActTime.NewRow();
   dract["ActivityName"] = string.Format("Activity{0}", n);
   dract["ActivityNodeID"] = n;
   tblActTime.Rows.Add(dract);
}

gdActivityTime.DataSource = tblActTime;
gdActivityTime.DataBind();

//initialize start/end time for all time picker in the grid:

TimeSpan dtStart = new TimeSpan(0, 8, 0);
TimeSpan dtEnd = new TimeSpan(0, 21, 0);

foreach (GridDataItem pkgItem in gdActivityTime.MasterTableView.Items)
{
    DataRowView drx = pkgItem.DataItem as DataRowView;
    RadTimePicker dp = pkgItem.FindControl("pkDesignatedStartTime") as RadTimePicker;
    dp.TimeView.StartTime = dtStart;
    dp.TimeView.EndTime = dtEnd;
}

Thank you in advance.

 

1 Answer, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 09 Jan 2009, 08:15 AM
Hello Ken,

I just tested this with the latest versions of our controls and it is working as expected. Please find attached a runnable sample created based on the code and markup you pasted.

Kind regards,
Pavel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Calendar
Asked by
Ken
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Share this question
or