Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

"Day View" Calendar Hack

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    "Day View" Calendar Hack

    Hi Everyone,

    I am currently still on version 10.5 but this could easily apply to version 11. I was looking for a way to show a basic "day" calendar view for my application. Basically I wanted a simple day calendar broken out by hours that was easy to read and looked like a calendar. I know in version 10.5 and 11 there are calendar options available and they are very nice, but I needed something that was easy to customize and used standard grid technology.

    So using a standard read only grid and events I was able to build something very nice I think. Basically I wrote a lot of Xbasic code that uses the OnExistingRowRender and the OnAfterExistingRowRender to build the calendar look and feel. I have included the code and an image of the result below.

    New_Display_Calendar.jpg


    To implement it yourself here are some key points...

    1) Use a read only grid.
    2) You need a date and time field in the grid of course.
    3) The color coding you see in the image where just conditional formatting I added to some fields.
    4) Add a search field on the read only grid and set hide grid when no search is active.
    5) You will probably need to modify the code a bit to suit your needs. I make absolutely no warranty to its use and you can use it on your application as you see fit. It could probably be cleaned up a bit and made more flexible but I will leave that to someone else if they want to work on it.
    6) I was able to get the concept of how the OnExistingRowRender works from some comments on the forum so thanks to the forum for help.

    Let me know what you think or any ideas to improve it. (Code below)

    Cheers,

    Scott

    Here is the code for the OnExistingRowRender:

    dim date_new as c
    dim date_old as c
    dim time_new as c
    dim time_old as c
    dim date_display_loop as c


    'HTML Formatting...

    dim date_format as c
    dim row_format as c
    dim break_after_date as c
    dim break_after_time as c
    dim early_description as c

    date_format = "<div style=\"width:980px;background-color: #e1dfdf;height: 25px;\"><SPAN STYLE=\"color: black; font-size: 12pt;\">"
    row_format = "<SPAN STYLE=\"color: #969696; font-size: 10pt\">"
    break_after_date = "<br>"
    break_after_time = ""
    break_before_time = "<br><hr>"


    early_description = "<hr>12:00 am to 7:00 am and services with no time assigned</span>"





    if eval_valid("e.rtc.date")=.f. 'if e.rtc.Grupo hasnt been set (eg. first row)
    e.rtc.date = "$nada$" 'set to a dummy value
    e.rtc.time = "$nada$"


    end if
    Date_old = e.rtc.date 'The Grouping field value from the previous record
    Time_old = e.rtc.time



    Date_new = e.rowData.data("Date") 'The Grouping field value from the current record
    time_new = e.rowData.data("Time") 'Time field


    date_new = REMSPECIAL(date_new)
    time_new = REMSPECIAL(time_new)
    time_hour = substr(time_new,1,2)
    'debug(1)

    time_am_pm = substr(time_new,9,2)

    if val(time_hour) != 12
    if time_am_pm = "pm"
    time_hour = val(time_hour) + 12
    end if
    end if

    if val(time_hour) = 12
    if time_am_pm = "am"
    time_hour = 01
    end if
    end if



    if date_new <> date_old
    if date_old = "$nada$"


    date_display = e.rowData.data("Date")

    date_display2 = format_data(date_display,"4")

    'Ok, so we know its the first occurence, but that doesnt stop us needing to create the initial date line and 7:00 am to 12:00 pm line, because no matter
    'what that is coming. So lets set that up first!

    date_display_loop = date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description

    'Now - what time is it? FIgure that out and generate the entries...

    if val(time_hour) < 7 'do nothing, we alredy created the early morning entry...

    else if time_hour = "" 'blank time, do nothing.

    else if val(time_hour) >= 18 'in this case create all the hours plus the final evening notation

    dim loop as n
    dim next as n
    dim time_counter as c



    time_counter = 6

    time_check = 17

    loop_counter = 6
    next = 100

    for loop = loop_counter to next


    if val(time_counter) + 1 < 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time

    else if val(time_counter) + 1 = 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time

    else


    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time

    end if


    time_counter = val(time_counter) + 1

    if loop = 16

    date_display_loop = date_display_loop + break_before_time + row_format + "6:00 pm to 12:00 am" + "</span>"

    exit for

    end if

    next loop




    else ' ok we have a time value, create the entry.

    dim loop as n
    dim next as n
    dim time_counter as c

    time_counter = 6

    time_check = val(time_hour) - 1

    loop_counter = 6
    next = 100

    for loop = loop_counter to next

    if val(time_counter) + 1 < 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time


    else if val(time_counter) + 1 = 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time


    else

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time

    end if


    time_counter = val(time_counter) + 1

    if loop >= time_check

    exit for

    end if

    next loop


    end if ' this end if is for checking what time it was.






    date_format = <<%html%
    <tr bgcolor="#ffffff">
    <td colspan="30">
    <font color="#000000" size=3 >%html% + date_display_loop + <<%html%
    </font>
    </td>
    </tr>
    %html%


    e.htmlPrefix = date_format


    ' e.htmlPrefix = <<%html%
    ' <tr bgcolor="#ffffc0">
    ' <td colspan="10">
    ' <font color=#CC0000 size=3 >%html% + date_display_loop + <<%html%
    ' </font>
    ' </td>
    ' </tr>
    ' %html%



    end if 'end of is it $nada$
    end if 'end of is it not the same date.


    if date_new <> date_old
    if date_old != "$nada$"

    date_display = e.rowData.data("Date")

    date_display2 = format_data(date_display,"4")

    'Its not the first occurence of a date
    'So before the new date, we need to build up the previous time entries.!!

    'First lets check to see if theere were entries late in the day...so we don't need to do anythin.

    if val(time_old) >= 18

    'So we know that the time old is no there. We just need to get todays date and figure out the time.

    date_display_loop = "<br>" + date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description

    else

    'What was the previous time...

    if time_old = "" 'so there were entries that had no times and nothing after that..

    'create the 7:00 am row and the enter the normal loop....

    time_old = "06"

    end if 'End if there was no times in the previous run.

    if val(time_old) <= 6
    time_old = 6
    end if


    'ok, so here we are still working on the previous day. If there wasn't any values with a time then they have been handled in the previous if
    'clause. So
    'no we need to create the previous working hours.

    'We need to build the html. So take the last time value, add 1, add it to the variab.e



    dim loop as n
    dim next as n

    loop_counter = time_old

    next = 16

    for loop = loop_counter to next

    'Dont need this if the previous day was 5 pm.

    if val(time_old) != 17

    if val(time_old) + 1 < 12

    date_display_loop = date_display_loop + break_before_time + row_format +(val(time_old) + 1) + " am" + "</span>" + break_after_time


    else if val(time_old) + 1 = 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1) + " pm" + "</span>" + break_after_time

    else

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1 - 12) + " pm" + "</span>" + break_after_time

    end if

    end if

    time_old = val(time_old) + 1

    next loop

    date_display_loop = date_display_loop + break_before_time + row_format + "6:00pm to 12:00am<br><br>"+ "</span>" + date_format + date_display2 + "</span></div>" + break_after_date + row_format + early_description


    end if ' there were entries late in the day so no need to generate a previous view.

    'Now we have the previous day taken care of! Now figure out today!

    if val(time_hour) < 7 'do nothing, we alredy created the early morning entry...

    else if time_hour = "" 'blank time, do nothing.

    else if val(time_hour) >= 18

    dim loop as n
    dim next as n
    dim time_counter as c

    time_counter = 6

    time_check = 17

    loop_counter = 6
    next = 100

    for loop = loop_counter to next

    'We dont need to enter this if its 17

    if val(time_old) != 17

    if val(time_counter + 1) < 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time


    else if val(time_counter) + 1 = 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time


    else


    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time

    end if

    end if

    time_counter = val(time_counter) + 1

    if loop = time_check

    date_display_loop = date_display_loop + "<br><br> 6:00 pm to 12:00 am"

    exit for

    end if

    next loop

    else ' ok we have a time value, create the entry.

    dim loop as n
    dim next as n
    dim time_counter as c

    time_counter = 6

    time_check = val(time_hour) - 1

    loop_counter = 6
    next = 100

    for loop = loop_counter to next

    if val(time_counter) + 1 < 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time


    else if val(time_counter) + 1 = 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time

    else


    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time

    end if

    time_counter = val(time_counter) + 1

    if loop = time_check

    exit for

    end if

    next loop


    end if ' this end if is for checking what time it was.



    date_format = <<%html%
    <tr bgcolor="#ffffff">
    <td colspan="30">
    <font color="#000000" size=3 >%html% + date_display_loop + <<%html%
    </font>
    </td>
    </tr>
    %html%


    e.htmlPrefix = date_format



    end if 'Is it the first occurence?
    end if 'Is it a new date?


    'debug(1)

    if date_new = date_old
    if time_hour != time_old 'only do something if the time is different....
    if time_hour != "" 'we don't want to do this unless its a real time, the previous time might have been 12;00 am to 7:00 am
    if val(time_hour) >= 7


    'debug(1)

    'Now - what time is it? FIgure that out and generate the entries...

    if val(time_hour) >= 18 'in this case create all the hours plus the final evening notation
    if val(time_old) < 18 'if we had a previous value dont create the data again!
    dim loop as n
    dim next as n
    dim time_counter as c

    if time_old = ""
    time_old = 6
    end if




    time_counter = time_old

    time_check = val(time_old) - 1


    loop_counter = time_old
    next = 100

    for loop = loop_counter to next

    'For the 5 pm ones just exit...we dont need an entry

    if val(time_old) != 17

    if val(time_counter) + 1 < 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" "</span>" + break_after_time


    else if val(time_counter) + 1 = 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time

    else


    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time

    end if

    end if

    time_counter = val(time_counter) + 1

    if loop >= 16

    date_display_loop = date_display_loop + row_format + "<br><br><hr> 6:00 pm to 12:00 am" "</span>"

    exit for

    end if

    next loop
    end if ' end if was the previous on less than 16



    else ' ok we have a time value, create the entry.

    dim loop as n
    dim next as n
    dim time_counter as c

    if time_old = ""
    time_old = 6
    end if

    if val(time_old) <= 6
    time_old = 6
    end if

    time_counter = time_old

    time_check = val(time_hour) - 1

    loop_counter = time_old
    next = 100

    for loop = loop_counter to next

    if val(time_counter) + 1 < 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " am" + "</span>" + break_after_time


    else if val(time_counter) + 1 = 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1) + " pm" + "</span>" + break_after_time
    else


    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_counter) + 1 - 12) + " pm" + "</span>" + break_after_time

    end if

    time_counter = val(time_counter) + 1

    if loop = time_check

    exit for

    end if

    next loop


    end if ' this end if is for checking what time it was.



    date_format = <<%html%
    <tr bgcolor="#ffffff">
    <td colspan="30">
    <font color="#000000" size=3 >%html% + date_display_loop + <<%html%
    </font>
    </td>
    </tr>
    %html%


    e.htmlPrefix = date_format

    end if 'old time is greater than 7
    end if 'end of time old.
    end if 'end of is it $nada$
    end if 'end of is it not the same date.









    e.rtc.date = date_new
    e.rtc.time = time_hour

    Here is the code for the OnAfterExistingRowRender

    'HTML Formatting...

    dim date_format as c
    dim row_format as c
    dim break_after_date as c
    dim break_after_time as c
    dim early_description as c

    date_format = "<div style=\"width:970px;background-color: #e1dfdf;height: 25px;\"><SPAN STYLE=\"color: black; font-size: 12pt;\">"
    row_format = "<SPAN STYLE=\"color: #969696; font-size: 10pt\">"
    break_after_date = "<br>"
    break_after_time = ""
    break_before_time = "<br><hr>"



    dim date_display_loop as c
    Time_old = e.rtc.time

    if val(time_old) >= 18

    'So we know that the time old is no there. We just need to get todays date and figure out the time.

    ' do nothing! we hav everyhthing we need

    else

    'What was the previous time...

    if time_old = "" 'so there were entries that had no times and nothing after that..

    'create the 7:00 am row and the enter the normal loop....

    time_old = "06"

    end if 'End if there was no times in the previous run.

    if val(time_old) <= 6
    time_old = 6
    end if


    'ok, so here we are still working on the previous day. If there wasn't any values with a time then they have been handled in the previous if
    'clause. So
    'no we need to create the previous working hours.

    'We need to build the html. So take the last time value, add 1, add it to the variab.e



    dim loop as n
    dim next as n

    loop_counter = time_old

    next = 16

    for loop = loop_counter to next

    'Dont need this if the previous day was 5 pm.

    if val(time_old) != 17

    if val(time_old) + 1 < 12

    date_display_loop = date_display_loop + break_before_time + row_format +(val(time_old) + 1) + " am" + "</span>" + break_after_time


    else if val(time_old) + 1 = 12

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1) + " pm" + "</span>" + break_after_time

    else

    date_display_loop = date_display_loop + break_before_time + row_format + (val(time_old) + 1 - 12) + " pm" + "</span>" + break_after_time

    end if

    end if

    time_old = val(time_old) + 1

    next loop

    date_display_loop = date_display_loop + row_format + "<br><br><hr> 6:00 pm to 12:00 am" "</span>"

    end if ' there were entries late in the day so no need to generate a previous view.

    e.rtc.date = "$nada$" 'set to a dummy value
    e.rtc.time = "$nada$"
    '
    '
    ' e.html = <<%html%
    ' <tr bgcolor="#ffffc0">
    ' <td colspan="10">
    ' <font color=#CC0000 size=3 >%html% + date_display_loop + <<%html%
    ' </font>
    ' </td>
    ' </tr>
    ' %html%


    date_format = <<%html%
    <tr bgcolor="#ffffff">
    <td colspan="30">
    <font color="#000000" size=3 >%html% + date_display_loop + <<%html%
    </font>
    </td>
    </tr>
    %html%


    e.html = date_format
Working...
X