不过handsontable不能用jquery取对象
var
$$ = function(id) {
return document.getElementById(id);
},
container = $$('example1'),
exampleConsole = $$('example1console'),
autosave = $$('autosave'),
load = $$('load'),
save = $$('save'),
autosaveNotification,
hot; hot = new Handsontable(container, {
startRows: 8,
startCols: 6,
rowHeaders: true,
colHeaders: true,
afterChange: function (change, source) {
if (source === 'loadData') {
return; //don't save this change
}
if (!autosave.checked) {
return;
}
clearTimeout(autosaveNotification);
ajax('scripts/json/save.json', 'GET', JSON.stringify({data: change}), function (data) {
exampleConsole.innerText = 'Autosaved (' + change.length + ' ' + 'cell' + (change.length > 1 ? 's' : '') + ')';
autosaveNotification = setTimeout(function() {
exampleConsole.innerText ='Changes will be autosaved';
}, 1000);
});
}
}); Handsontable.Dom.addEvent(load, 'click', function() {
ajax('scripts/json/load.json', 'GET', '', function(res) {
var data = JSON.parse(res.response); hot.loadData(data.data);
exampleConsole.innerText = 'Data loaded';
});
}); Handsontable.Dom.addEvent(save, 'click', function() {
// save all cell's data
ajax('scripts/json/save.json', 'GET', JSON.stringify({data: hot.getData()}), function (res) {
var response = JSON.parse(res.response); if (response.result === 'ok') {
exampleConsole.innerText = 'Data saved';
}
else {
exampleConsole.innerText = 'Save error';
}
});
}); Handsontable.Dom.addEvent(autosave, 'click', function() {
if (autosave.checked) {
exampleConsole.innerText = 'Changes will be autosaved';
}
else {
exampleConsole.innerText ='Changes will not be autosaved';
}
});

把数据保存在本地

可在初始化或更新方法中设置persistentState为true:persistentStateSave, persistentStateLoad(把value存在valuePlaceholder.value), persistentStateReset,

为什么要使用persistentState?可以把多个实例存储的数据分隔开。

还不知道怎么用。

handsontable-developer guide-load and save的更多相关文章

  1. load、save方法、spark sql的几种数据源

    load.save方法的用法          DataFrame usersDF = sqlContext.read().load("hdfs://spark1:9000/users.pa ...

  2. SparkSQL读写外部数据源-基本操作load和save

    数据源-基本操作load和save object BasicTest { def main(args: Array[String]): Unit = { val spark = SparkSessio ...

  3. 37、数据源之通用的load和save操作

    一.通用的load和save操作 1.概述 对于Spark SQL的DataFrame来说,无论是从什么数据源创建出来的DataFrame,都有一些共同的load和save操作. load操作主要用于 ...

  4. Qt Load and Save Image Dialog 加载图片对话框

    在Qt中,我们想要通过对话框来打开某一个图片,可以通过使用QFileDialog来快速实现,参见以下代码: QString fileName = QFileDialog::getOpenFileNam ...

  5. Ehcache(2.9.x) - API Developer Guide, Key Classes and Methods

    About the Key Classes Ehcache consists of a CacheManager, which manages logical data sets represente ...

  6. Ehcache(2.9.x) - API Developer Guide, Write-Through and Write-Behind Caches

    About Write-Through and Write-Behind Caches Write-through caching is a caching pattern where writes ...

  7. spark SQL学习(load和save操作)

    load操作:主要用于加载数据,创建出DataFrame save操作:主要用于将DataFrame中的数据保存到文件中 代码示例(默认为parquet数据源类型) package wujiadong ...

  8. Yii 2 load() 和 save()

    我这里用的数据库是mongo 数据库 为栗子: public function load($data, $formName = null) { $scope = $formName === null ...

  9. netcore XmlDocument 使用Load和Save方法

    string path ="C://xxx/file" XmlDocument xmlDoc = new XmlDocument(); #if NET462 xmlDoc.Load ...

  10. Ehcache(2.9.x) - API Developer Guide, Cache Usage Patterns

    There are several common access patterns when using a cache. Ehcache supports the following patterns ...

随机推荐

  1. 走迷宫(用队列bfs并输出走的路径)

    #include <iostream> #include <stack> #include <string.h> #include <stdio.h> ...

  2. POJ 2395 Out of Hay(求最小生成树的最长边+kruskal)

    Out of Hay Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18472   Accepted: 7318 Descr ...

  3. Air test 基于屏幕比例实现滑动的方法

    # -*- encoding=utf8 -*- __author__ = "chenshanju" __docs__ = "基于iOS类实现滑动" from a ...

  4. 好记性不如烂笔头-linux学习笔记6keepalived实现主备操作

    Keepalived的作用是检测服务器的状态,如果有一台web服务器宕机,或工作出现故障,Keepalived将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替该服务器的工作,当服务器工 ...

  5. Javascript 日期 加减

    //create the date var myDate = new Date(); //add a day to the date myDate.setDate(myDate.getDate() + ...

  6. BDE 升级到FireDAC

    BDE  Query Replace Str in files   by cnpack tools TQueryTFDQuery dmdb->qrypub->Open(sql); fdme ...

  7. 新手C#重载、重写的学习2018.08.04

    重载:在同一类(class)中,使用相同的方法名称,不同的参数和(不一定)不同的返回值类型构造成的方法. 举例: class OverLoadTest { public void Hello() { ...

  8. awk编程基础

    一.awk介绍 awk(名字来源于三个创始人姓氏首字母)是linux系统下文本编辑工具,是一门编程语言,有自己的基本语法和流程控制.函数.awk简单高效.   二.awk的运行方法 例子:使用冒号:分 ...

  9. leetcode 21 Merge Two Sorted Lists 合并两个有序链表

    描述: 合并两个有序链表. 解决: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { if (!l1) return l2; if (!l2) ...

  10. Visual studio 2017编译 boost

    下载: https://www.boost.org/   或者 https://dl.bintray.com/boostorg/release/1.66.0/source/ 下载完成以后解压到自己想要 ...