Calendar [examples]

Click delegate

Optional. The name of a delegate script to be called when a cell in the calendar is clicked. Data is passed to the click delegate in JSON format. e.g.

calendar_click
function calendar_click(data)
{
	// You can handle a custom calendar cell click event here
	Lianja.writeLog(data);
};
{"database":"southwind","table":"employees_calendar","columns":"eventtitle,eventstart,eventend,eventrepeat,eventallday,eventtype",
"keyvalue":"Buchanan","keyexpr":"lastname","title":"Meeting","start_date":"2015-09-08","end_date":"2015-09-08","start_time":"09:00",
"end_time":"17:00","allDay":"true","repeat":"false","rowid":"42","id":0,"action":"eventclick","sectionid":"section2",
"eventtype":"eventtype","eventtypevalue":"Sales Meeting"}

Dynamic day backcolor

Optional. The name of a function in the Custom delegate library that returns dates and their associated background colors, allowing specific dates to be highlighted. e.g.

getdatecolors

The function should accept a parameter which will have one of two values: ‘dates’ or ‘colors’.

If the parameter is ‘dates’, the function should return a string containing comma-separated ISO format character string dates. These can contain a single ‘*’ to indicate either all years, all months or all days. The strings ‘sunday’ and ‘saturday’ are also recognized.

If the parameter is ‘colors’, the function should return a string containing comma-separated color strings (e.g. ‘red’ or ‘#FF0000’), one for each date in the dates string. The colors will be applied to the dates in order. e.g.

function getdatecolors(para1)
	if para1 = "dates"
		return ['2015-*-28','sunday','&(strftime("%F",dtoc(date())))','*-09-01']
	else
		return ['purple','yellow','blue','#FF0000']
	endif
endfunc

In the example above, the 28th of every month in 2015 will have a purple background, all Sundays will have a yellow background, the current date will have a blue background and September 1st every year will have a red background.

Dynamic event backcolor

Optional. The name of a function in the Custom delegate library that returns a color string (e.g. ‘red’ or ‘#FF0000’) to be used as the background color for a specific event type. e.g.

geteventback

The event type is passed as a parameter to the function. e.g.

function geteventback(para1)
	do case
	case para1 = "UK Bank Holiday"
		return 'red'
	case para1 = "US Public Holiday"
		return 'pink'
	otherwise // all other event types
		return 'white'
	endcase
endfunc

Note that event type / color pairs can also be specified in the Event type choices as described above.

Dynamic event forecolor

Optional. The name of a function in the Custom delegate library that returns a color string (e.g. ‘red’ or ‘#FF0000’) to be used as the foreground color for a specific event type. e.g.

geteventfore

The event type is passed as a parameter to the function. e.g.

function geteventfore(para1)
	do case
	case para1 = "UK Bank Holiday"
		return 'pink'
	case para1 = "US Public Holiday"
		return 'white'
	otherwise // all other event types
		return 'black'
	endcase
endfunc

Note that event type / color pairs can also be specified in the Event type choices as described above.

https://www.lianja.com/doc/index.php/Calendar_Options


 

Advertisements

Calendar

Q:
I need to filter the data for the calendar section based on a public variable. I cannot find a similar “Where Condition” attribute for the calendar section?
A:
Filter

Screen Shot 2015-01-25 at 10.18.32 AM


Q:
Is there a variable or attribute that stores the current month and year displayed in calendar section

A:
When you specify a “Click delegate” for the calendar section in the attributes, when the user clicks on an event or clicks on a calendar cell the click delegate is called with a JSON encoded string as an argument.
In your case, as you are building a desktop App you can use json_decode() to decode the argument into an object.
This object then has members:
start_date
end_date
start_time
end_time
You can look at the object using json_decode( arg )
Example desktop calendar click delegate:
proc myCalendarClickDelegate( arg )
? json_decode(arg)
endproc


Q:
I notice under the calendar options the following attributes
a) Click Delegate
b) Dynamic day backcolor
c) Dynamic event backcolor
d) Dynamic event forecolor
In my case, my table has a field that indicate the type of shift and I want to color the days in a month based on the shift type

A:

As the calendar is being rendered, for each record the “delegate” functions for the dynamic coloring are called. When they are called the active record is in the currently selected cursor.

You can therefore just inspect the fields in the record (or lookup some other data in another table) and return a color code. This color code is a string and can be any of the standard web colors e.g. “pink”, “lightgreen” etc or it can be a HTML/CSS style color code e.g. “#cfcfcf”.
The delegate settings are in the attributes. See below.

Screen Shot 2014-12-27 at 3.46.25 PM

If you read the source code of calendar_view.rsp in the library directory you will see how this is achieved.
Also notice in the screenshot that “Event Type choices” determine what appears in the drop down list and also the color that corresponds to that type of event.