[英]How to load events from php/mysql for DojoX Calendar?
I want to customize the DojoX Calendar widget ( http://dojotoolkit.org/reference-guide/1.8/dojox/calendar.html ) in order to dinamically load events from php/mysql. 我想自定义DojoX日历小部件( http://dojotoolkit.org/reference-guide/1.8/dojox/calendar.html ),以便从php / mysql中动态加载事件。
I've a db table where events are stored and events, after first initialization, should be retrieved again (ajax call?) ONLY when I change calendar view, for example when I click to go to previous/next month. 我有一个db表,其中存储了事件,并且在第一次初始化之后,应该再次检索事件(ajax调用?),仅当我更改日历视图时,例如当我点击进入上一个/下个月时。 So my question are: Where have I to change JS code referring to Dojox Calendar example/documentation page?
所以我的问题是:我在哪里更改JS代码,参考Dojox日历示例/文档页面? What kind of changes have I to do in JS code in order to call (http post or get) PHP file and getting new JSON dataset when month changes?
我需要在JS代码中进行哪些更改才能调用(http post或get)PHP文件并在月份更改时获取新的JSON数据集?
I've read this thread too: dojox.calendar and JsonRest - how to update? 我也读过这个帖子: dojox.calendar和JsonRest - 如何更新?
but: 但:
I think somebody has already developed this kind of solution... 我觉得有人已经开发出这种解决方案......
I hope someone could help me, thanks! 我希望有人可以帮助我,谢谢!
Depending on how many events you have, you can just load every event into the calendar initially and no matter what month/view you scroll too, the events will be present. 根据您拥有的事件数量,您可以将每个事件最初加载到日历中,无论您滚动的月份/视图是什么,事件都将存在。
How, so far as an example on how to load in events from a database backend: 到目前为止,如何从数据库后端加载事件的示例如何:
Sure. 当然。 here you go:
干得好:
Let's assume that your php
file (let's call it calendar-events.php
) returned the following event data from your mysql table in the following JSON
format: 假设您的
php
文件(我们称之为calendar-events.php
)以下列JSON
格式从您的mysql表返回以下事件数据:
{
"items": [
{
"id":"0",
"summary":"An event in the calendar",
"calendar":"calendar1",
"startTime":"1351756800",
"endTime":"1351771200"
}
]
}
Now, create the store that retrieves the data: 现在,创建检索数据的商店:
var calendarStore = new ItemFileWriteStore({
url: "calendar-events.php",
clearOnClose: true,
urlPreventCache: true
});
Finally, set the store to the calendar
and render the calendar
: 最后,将商店设置为
calendar
并呈现calendar
:
calendar = new Calendar({
store: calendarStore,
dateInterval: "month",
region: "center",
roundToDay: false,
editable: false,
decodeDate: function(s){
return new Date(s * 1000);
},
style: "position:absolute;left:10px;top:10px;bottom:10px;right:10px;",
columnViewProps: {
minHours: 0,
maxHours: 24
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.