search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

DayPilot Scheduler - Is this possible?

Asked by Ozzie
13 years ago.

HI All,

I am trying to create a booking application that would work in the following way:

1 - Would only show the current day - but the user would have the option to also choose a day <- I think i have this.

2 - The left hand side would show the available rooms for booking <- I think i have this.

3 - The header across the top would be group into blocks of time and named i.e. Lesson 1 - 9:00 - 10:00, Less 2 - 10:15 - 11:15 and so on

4 - Show the bookings for each room and thier relevant lesson <- I think i have this

Any guidance would be great, mainly on point 3 as this is really stumping me.

Answer posted by Dan Letecky [DayPilot]
13 years ago.

If the lessons were always inside a CellGroupBy unit (e.g. an hour), you could use smaller units for time cells (e.g. CellDuration=15) and hide some of them:

http://www.daypilot.org/scheduler-hiding-non-business-hours.html

However, this doesn't seem to be the case (10:15 - 11:15). I would probably store lesson order number as the hour part of the start and end and override the time headers using BeforeTimeHeaderRender.

Example:

Lesson 1: start 2011-09-12T00:00:00 end 2011-09-12T01:00:00
Lesson 2: start 2011-09-12T01:00:00 end 2011-09-12T02:00:00
etc.

CellDuration=60
BusinessBeginsHour=0
BusinessEndsHour=6 (for 6 lessons a day)
ShowNonBusiness=true

BeforeTimeHeaderRender:

    protected void DayPilotScheduler1_BeforeTimeHeaderRender(object sender, DayPilot.Web.Ui.Events.BeforeTimeHeaderRenderEventArgs e)
    {
      switch (e.Start.Hour) {
        case 0: e.InnerHTML = "9:00 - 10:00"; break;
        case 1: e.InnerHTML = "10:15 - 11:15"; break;
        // etc
      }
    }
Comment posted by Anonymous
13 years ago.

Yep i see that now, many thanks for the point in the right direction.

This should do just what i need :-)

I will be back though.......

Comment posted by Ozzie
13 years ago.

Hi,

Told you I would be back.

I have it all working as expected and look great however this is with static and hardcoded values for the time header(s).

As I do not really know how many lessons there may be and what users may name them I want to keep these in a database, easy enough, but eaht I am having trouble getting my head round is the method that could be used to pull the data from the database and add it to the timeheader.

I see that you use a select statement based on e.Start.Hour but how i do this if pulling direct from a table?

I know how many lessons there are as this is part of the select query and these are pulled out in order of start time so would it be as simple as to ensure that each records out is given a incrementing number starting at zero and this would correspond with the lesson slot on the scheduler?

Comment posted by Ozzie
13 years ago.

Have got it working :-)

Used the follwing and this works fine:

[code]

Protected Sub DayPilotScheduler1_BeforeTimeHeaderRender(sender As Object, e As DayPilot.Web.Ui.Events.BeforeTimeHeaderRenderEventArgs)

Dim objConnection As SqlConnection
Dim objCommand As SqlCommand

objConnection = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("OPSDConnectionString").ConnectionString)

objCommand = New SqlCommand("SELECT name, time_start, time_end FROM tblrb_periods WHERE bookable = 1 ORDER BY time_start asc", objConnection)

Try
objConnection.Open()
Dim objPeriodDataReader As SqlDataReader
Dim startHour As Integer = 0
objPeriodDataReader = objCommand.ExecuteReader()

While objPeriodDataReader.Read()

Dim strStart As String = objPeriodDataReader("time_start").ToString()
Dim strEnd As String = objPeriodDataReader("time_end").ToString()

'Remove trailing :00 from time
strStart = strStart.Substring(0, strStart.Length - 3)
strEnd = strEnd.Substring(0, strEnd.Length - 3)

If startHour = e.Start.Hour Then

e.InnerHTML = "<div style='position:relative'><span style='position:relative; left: -10px;'>" & objPeriodDataReader("name") & "</div>"
e.ToolTip = objPeriodDataReader("name") & " - " & strStart & " - " & strEnd

If Not e.IsColGroup Then
e.InnerHTML = "<div style='color:gray; font-size:8pt; position:relative'><span style='position:relative; left: -10px;'>" & strStart & " - " & strEnd & "</span></div>"
End If

End If

startHour = startHour + 1

End While

Catch ex As Exception

'Inform of the error

Finally
objCommand.Dispose()
objConnection.Close()
objConnection.Dispose()

End Try

End Sub

[/code]

The only other that needs doing is you have to set the BusinessEndsHour equal to the number of leesons/periods you have have. (remember this is a zero based count i.e. 0 1 2 3 4 would be BusinessEndsHour=5)

Now to populate with bookings :-)

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.