Custom Elements Documentation
Getting Started
jqxScheduler is a HTML Element which displays a set of appointments in day, week, month, timeline day, timeline week and timeline month and agenda views.Every UI element from jQWidgets toolkit needs its JavaScript files to be included in order to work properly.
The first step is to create html page and add links to the javascript files and
css dependencies to your project.
The jqxScheduler element requires the following
files:
The next step is to add the html element within the body of the html page.<script type="text/javascript" src="../scripts/webcomponents-lite.min.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxcore.elements.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxdate.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxdata.export.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="../jqwidgets/jqxmenu.js"></script><script type="text/javascript" src="../jqwidgets/jqxradiobutton.js"></script><script type="text/javascript" src="../jqwidgets/jqxcheckbox.js"></script><script type="text/javascript" src="../jqwidgets/jqxlistbox.js"></script><script type="text/javascript" src="../jqwidgets/jqxdropdownlist.js"></script><script type="text/javascript" src="../jqwidgets/jqxcombobox.js"></script><script type="text/javascript" src="../jqwidgets/jqxwindow.js"></script><script type="text/javascript" src="../jqwidgets/jqxtooltip.js"></script><script type="text/javascript" src="../jqwidgets/jqxnumberinput.js"></script><script type="text/javascript" src="../jqwidgets/jqxcalendar.js"></script><script type="text/javascript" src="../jqwidgets/jqxdatetimeinput.js"></script><script type="text/javascript" src="../jqwidgets/globalization/globalize.js"></script>
The last step is to initialize the element settings:<jqx-scheduler settings="elementSettings"></jqx-scheduler>
To call a function(method), you need to pass the method name and parameters(if any) in the jqxScheduler's instance.<script type="text/javascript">
JQXElements.settings["elementSettings"] =
{
date:date,width:850,height:600, source:adapter, view:"weekView",showLegend:true, resources:resources, appointmentDataFields:appointmentDataFields, views:views,appointmentOpacity:0.7, theme:"light"
}
</script>
To get the result of a function after calling it, you can use the following syntax:<script>
window.onload = function () {
var element = document.querySelector("jqx-scheduler");
element.addAppointment(1,Item1);
}
</script>
To set a property(option), you need to use the property name and value(s) along with the jqxScheduler's instance.<script>
window.onload = function () {
var element = document.querySelector("jqx-scheduler");
var result = element.exportData();
}
</script>
You can also set properties of HTML Elements by using Attributes. Traditionally, attributes are used to set the initial state of an element. Properties with camelCase naming have dash-based attributes. For example: A property "dataSource" will have an attribute called "data-source".window.onload = function() {
document.querySelector("jqx-scheduler").appointmentOpacity = 0.7;
}
To get a property(option), you need to use the property name along with the jqxScheduler's instance.
window.onload = function() {
var propertyValue = document.querySelector("jqx-scheduler").appointmentOpacity;
}
Event binding can be defined in the HTML as an attribute. The syntax is: 'on-' and the event's name. Event Names with camelCase naming have dash-based attributes. The attribute's value is the event handler's name. The addEventListener
function can also be used for event binding.
<script>
window.onload = function () {
var element = document.querySelector("jqx-scheduler");
element.addEventListener("appointmentChange", function(event){
// Your code here
});
}
</script>
Example
<!DOCTYPE html>
<html lang="en">
<head>
<title id='Description'>Scheduler Custom Element</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" />
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.light.css" type="text/css" />
<link rel="stylesheet" href="../../styles/demos.css" type="text/css" />
<script type="text/javascript" src="../../scripts/webcomponents-lite.min.js"></script><script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script><script type="text/javascript" src="../../jqwidgets/jqxcore.elements.js"></script><script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script><script type="text/javascript" src="../../jqwidgets/jqxdate.js"></script><script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script><script type="text/javascript" src="../../jqwidgets/jqxscheduler.js"></script><script type="text/javascript" src="../../jqwidgets/jqxscheduler.api.js"></script><script type="text/javascript" src="../../jqwidgets/jqxdatetimeinput.js"></script><script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script><script type="text/javascript" src="../../jqwidgets/jqxcalendar.js"></script><script type="text/javascript" src="../../jqwidgets/jqxtooltip.js"></script><script type="text/javascript" src="../../jqwidgets/jqxwindow.js"></script><script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script><script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script><script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script><script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script><script type="text/javascript" src="../../jqwidgets/jqxnumberinput.js"></script><script type="text/javascript" src="../../jqwidgets/jqxradiobutton.js"></script><script type="text/javascript" src="../../jqwidgets/jqxinput.js"></script><script type="text/javascript" src="../../jqwidgets/globalization/globalize.js"></script><script type="text/javascript" src="../../jqwidgets/globalization/globalize.culture.de-DE.js"></script><script>var appointments = new Array();var appointment1 = {id: "id1",description: "George brings projector for presentations.",location: "",subject: "Quarterly Project Review Meeting",calendar: "Room 1",start: new Date(2016, 10, 23, 9, 0, 0),end: new Date(2016, 10, 23, 16, 0, 0)}var appointment2 = {id: "id2",description: "",location: "",subject: "IT Group Mtg.",calendar: "Room 2",start: new Date(2016, 10, 24, 10, 0, 0),end: new Date(2016, 10, 24, 15, 0, 0)}var appointment3 = {id: "id3",description: "",location: "",subject: "Course Social Media",calendar: "Room 3",start: new Date(2016, 10, 27, 11, 0, 0),end: new Date(2016, 10, 27, 13, 0, 0)}var appointment4 = {id: "id4",description: "",location: "",subject: "New Projects Planning",calendar: "Room 2",start: new Date(2016, 10, 23, 16, 0, 0),end: new Date(2016, 10, 23, 18, 0, 0)}var appointment5 = {id: "id5",description: "",location: "",subject: "Interview with James",calendar: "Room 1",start: new Date(2016, 10, 25, 15, 0, 0),end: new Date(2016, 10, 25, 17, 0, 0)}var appointment6 = {id: "id6",description: "",location: "",subject: "Interview with Nancy",calendar: "Room 4",start: new Date(2016, 10, 26, 14, 0, 0),end: new Date(2016, 10, 26, 16, 0, 0)}appointments.push(appointment1);appointments.push(appointment2);appointments.push(appointment3);appointments.push(appointment4);appointments.push(appointment5);appointments.push(appointment6);// prepare the datavar source ={dataType: "array",dataFields: [{ name: 'id', type: 'string' },{ name: 'description', type: 'string' },{ name: 'location', type: 'string' },{ name: 'subject', type: 'string' },{ name: 'calendar', type: 'string' },{ name: 'start', type: 'date' },{ name: 'end', type: 'date' }],id: 'id',localData: appointments};var date = new jqx.date(2016, 11, 23);var adapter = new jqx.dataAdapter(source);var resourcesSource = new jqx.dataAdapter(source);var resources ={colorScheme: "scheme05",dataField: "calendar",source: resourcesSource};var appointmentDataFields = {from: "start",to: "end",id: "id",description: "description",location: "location",subject: "subject",resourceId: "calendar"};var views = ['dayView','weekView','monthView'];JQXElements.settings["schedulerSettings"] = {date:date,width:850,height:600, source:adapter, view:"weekView",showLegend:true, resources:resources, appointmentDataFields:appointmentDataFields, views:views,appointmentOpacity:0.7, theme:"light"}</script></head><body><jqx-scheduler settings="schedulerSettings"></jqx-scheduler></body></html>