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

Add label to timeslot dynamically and display

4 Answers 41 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Raju
Top achievements
Rank 1
Raju asked on 31 Jan 2013, 12:50 PM
How to add label to timeslot and assign some text to it ?

Thanks
Raju

4 Answers, 1 is accepted

Sort by
0
Raju
Top achievements
Rank 1
answered on 01 Feb 2013, 05:14 AM
i am able to add label to timeslot. But label is not visible in month but it is visible in day view.. 
if (e.TimeSlot.Appointments.Count > 3)
{
int temp = e.TimeSlot.Appointments.Count - 3;

    Label lb = new Label();
lb.Text = temp.ToString() + "more..";
lb.CssClass = "raju";

e.TimeSlot.Control.Controls.AddAt(0, lb);

    radTeacherSchedulerAssignments.Appointments[Convert.ToInt32(e.TimeSlot.Index)].Owner.MonthView.VisibleAppointmentsPerDay = 3;
    
}

How to show it in month view
0
Plamen
Telerik team
answered on 04 Feb 2013, 10:49 AM
Hi Raju,

 
Here is one way to achieve this in MonthView:

protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
   {
       RadScheduler scheduler = (RadScheduler)sender;
       if (scheduler.SelectedView==SchedulerViewType.MonthView)
       {
           if (e.TimeSlot.Appointments.Count>0)//count of visible appointments
           {
                Label countLabel = new Label();
               int realCountOfAppointments= scheduler.Appointments.GetAppointmentsInRange(e.TimeSlot.Start, e.TimeSlot.End).Count;//count of all appointments in the timespan
               countLabel.Text = "Today No Task:" + realCountOfAppointments;
                e.TimeSlot.Control.Controls.AddAt(4, countLabel);
           }
       }

Hope this will be helpful.

Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Oneview Corp
Top achievements
Rank 1
answered on 15 Aug 2015, 08:11 PM

Hi,

Does this only work for MonthView?

I tried to add a label to a timeslot in the week view and got a runtime error that e.TimeSlot.Control is null. 

I am trying to display a label on all the timeslot that spells what time is it (for example 9:15am). This is to make the slot look like a button that the users can click on.  It is easier for users to know what slot they are booking. Just blank spaces are a bit confusing for normal folks.

 

Thanks

Nitin

0
Plamen
Telerik team
answered on 18 Aug 2015, 06:54 AM
Hi,

Here is the code that worked correctly at my side in Day and weekView:
protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
  {
      Label countLabel = new Label();
    
      countLabel.Text = "Today No Task:";
      e.TimeSlot.Control.Controls.AddAt(1, countLabel);
  }

Hope this will help you solve the issue.

Regards,
Plamen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Scheduler
Asked by
Raju
Top achievements
Rank 1
Answers by
Raju
Top achievements
Rank 1
Plamen
Telerik team
Oneview Corp
Top achievements
Rank 1
Share this question
or