IndexedDB 为 CRUD 操作占用了相对较多的代码,因此教程已被严重简化,以免因实现细节而使其过载。还有一个完整的工作 CRUD 示例,检查这个包的“/samples/CalendarApp/”文件夹:http:
//dhtmlx.com/x/download/regular/dhtmlxScheduler_windows.zip
至于多点触控问题,很可能会在最近的时间修复。当前版本的软件包基于 dhtmlxScheduler3.7,我们将把它更新到 4.0,它对基于 Windows 的触摸设备进行了改进。
这是一个数据库处理的例子,类似于它在 dhtmlx 网站的应用程序中的处理方式。
//connect to indexedDb and fire the callback on success
function connect(callback){
try{
var db = null;
var req = window.indexedDB.open("SchedulerApp", 1);
req.onsuccess = function (ev) {
db = ev.target.result;
if(callback)//fire a callback on connect
callback(db);
}
req.onupgradeneeded = function(e){
//The event is fired when connecting to the new database, or on version change.
//This is the only place for defining database structure(object stores)
var db = ev.target.result;
if (!db.objectStoreNames.contains("events")) {
//create datastore, set 'id' as autoincremental key
var events = db.createObjectStore("events", { keyPath: "id", autoIncrement: true });
}
}
}catch(e){
}
}
//add js object to the database and fire callback on success
function insertEvent(data, callback) {
connect(function (db) {
var store = db.transaction("events", "readwrite").objectStore("events");
var updated = store.add(data);
updated.onsuccess = function (res) {
callback(res.target.result);
}
});
}
// use all defined above with the dhtmlxScheduler
// when user adds an event into the scheduler - it will be saved to the database
scheduler.attachEvent("onEventAdded", function (id) {
var ev = copyEvent(scheduler.getEvent(id));//where copyEvent is a helper function for deep copying
delete ev.id;//real id will be assigned by the database
insertEvent(ev, function (newId) {
scheduler.changeEventId(id, newId);//update event id in the app
});
return true;
});
但是,我不能保证它会立即工作,我目前无法测试代码。我还建议您查看MSDN上的这些文章
仅供参考,我为 DHTMLX 工作