Add label to timeslot dynamically and display

5 posts, 0 answers
  1. Raju
    Raju avatar
    16 posts
    Member since:
    Dec 2012

    Posted 31 Jan 2013 Link to this post

    How to add label to timeslot and assign some text to it ?

    Thanks
    Raju
  2. Raju
    Raju avatar
    16 posts
    Member since:
    Dec 2012

    Posted 31 Jan 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Plamen
    Admin
    Plamen avatar
    2733 posts

    Posted 04 Feb 2013 Link to this post

    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.
  5. Oneview Corp
    Oneview Corp avatar
    18 posts
    Member since:
    Sep 2009

    Posted 15 Aug 2015 in reply to Plamen Link to this post

    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

  6. Plamen
    Admin
    Plamen avatar
    2733 posts

    Posted 18 Aug 2015 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017