handsontable-常用配置
冻结单元格
var
//自动创建数据
myData = Handsontable.helper.createSpreadsheetData(100, 50),
container = document.getElementById('example1'),
positions = document.getElementById('positions'),
hot; hot = new Handsontable(container, {
data: myData,
colWidths: [47, 47, 47, 47, 47, 47, 47, 47, 47, 47],
//显示行头和列头
rowHeaders: true,
colHeaders: true,
//冻结单元格
fixedRowsTop: 2,
fixedColumnsLeft: 2
}); setInterval(function () {
var str = '';
//获得可见首行的序号
str += 'RowOffset: ' + hot.rowOffset(); positions.innerHTML = str;
}, 100);
手动调整行列大小
var
container = document.getElementById('example1'),
hot; hot = new Handsontable(container, {
data: Handsontable.helper.createSpreadsheetData(200, 10),
rowHeaders: true,
colHeaders: true,
//设置列的宽度
colWidths: [55, 80, 80, 80, 80, 80, 80],
//设置行的宽度,第四行是默认的
rowHeights: [50, 40, 100],
//手动调整列的宽度
manualColumnResize: true,
manualRowResize: true
});
滚动行列
http://docs.handsontable.com/0.16.0/demo-scrollbars.html
列的扩展
var
container1 = document.getElementById('example1'),
hot1; hot1 = new Handsontable(container1, {
data: Handsontable.helper.createSpreadsheetData(40, 6),
colWidths: 47,
rowHeaders: true,
colHeaders: true,
//扩展最后一列,其他列的宽度是47
stretchH: 'last',
//把table的宽度设为容器的宽度,列平分宽度
stretchH: 'all',
//默认值
stretchH: 'none',
//右键可用,默认为undefined
contextMenu: true
});
列的冻结:需要开启contextMenu
var
myData = Handsontable.helper.createSpreadsheetData(200, 100),
container = document.getElementById('example1'),
hot; hot = new Handsontable(container, {
data: myData,
rowHeaders: true,
colHeaders: true,
fixedColumnsLeft: 2,
contextMenu: true,
//列的手动冻结
manualColumnFreeze: true
});
行列的移动:列头左侧,行头上侧
var
example1 = document.getElementById('example1'),
hot; hot = new Handsontable(example1, {
data: Handsontable.helper.createSpreadsheetData(200, 20),
rowHeaders: true,
colHeaders: true,
manualColumnMove: true,
manualRowMove: true
});
当前元素高亮
var
data = [
['', 'Kia', 'Nissan', 'Toyota', 'Honda'],
['2013', 10, 11, 12, 13],
['2014', 20, 11, 14, 13],
['2015', 30, 15, 12, 13]
],
container = document.getElementById('example1'),
hot; hot = Handsontable(container, {
data: data,
minRows: 5,
minCols: 6,
//指定当前行的名字
currentRowClassName: 'currentRow',
//指定当前列的名字
currentColClassName: 'currentCol',
rowHeaders: true,
colHeaders: true
});
//选择元素
hot.selectCell(2,2);
分组:也可以设置groups:true,但是这种方式没有涉及到细节
var
example1 = document.getElementById('example1'),
settings,
hot; settings = {
data: Handsontable.helper.createSpreadsheetData(200, 20),
rowHeaders: true,
colHeaders: true,
groups: [
{
cols: [0, 2]
},
{
cols: [3, 7]
},
{
cols: [5, 7]
},
{
rows: [0, 4]
},
{
rows: [5, 7]
},
{
rows: [2, 4]
}
]
};
hot = new Handsontable(example1, settings);
Pre-populating new rows
Sorting data
可以使用array.prototype.sort(),排好序之后,在render(),不过这样会改变数据源的结构。如果想保持数据源不被破坏,需要使用如下方法:
columnSorting为true,表示可以排序,但是还没排好序
columnSorting为object,配置一些参数
检查是否开启排序
hot.sortingEnabled ? doSomething() : doSomethingElse();
是否排好序
return hotInstance.sortingEnabled && typeof hotInstance.sortColumn !== 'undefined';
//sortOrderistrue, then the order is ascending, otherwise, the order is descending.
排序的三种方法
1、columnSorting
2、点击表头:最常用
3、调用sort():如果开启了columnSorting,则可以使用sort(0, false)方法
Pagination
http://docs.handsontable.com/0.16.0/demo-pagination.html#3
handsontable-常用配置的更多相关文章
- logback 常用配置详解<appender>
logback 常用配置详解 <appender> <appender>: <appender>是<configuration>的子节点,是负责写日志的 ...
- 【转】logback logback.xml常用配置详解(三) <filter>
原创文章,转载请指明出处:http://aub.iteye.com/blog/1110008, 尊重他人即尊重自己 详细整理了logback常用配置, 不是官网手册的翻译版,而是使用总结,旨在更快更透 ...
- 【转】logback logback.xml常用配置详解(二)<appender>
原创文章,转载请指明出处:http://aub.iteye.com/blog/1101260, 尊重他人即尊重自己 详细整理了logback常用配置, 不是官网手册的翻译版,而是使用总结,旨在更快更透 ...
- 【转】logback logback.xml常用配置详解(一)<configuration> and <logger>
原创文章,转载请指明出处:http://aub.iteye.com/blog/1101260, 尊重他人即尊重自己 详细整理了logback常用配置, 不是官网手册的翻译版,而是使用总结,旨在更快更透 ...
- 【转】logback 常用配置详解(序)logback 简介
原创文章,转载请指明出处:http://aub.iteye.com/blog/1101222, 尊重他人即尊重自己 详细整理了logback常用配置, 不是官网手册的翻译版,而是使用总结,旨在更快更透 ...
- logback 常用配置详解(二) <appender>
logback 常用配置详解(二) <appender> <appender>: <appender>是<configuration>的子节点,是负责写 ...
- SpringBoot常用配置简介
SpringBoot常用配置简介 1. SpringBoot中几个常用的配置的简单介绍 一个简单的Spring.factories # Bootstrap components org.springf ...
- .net学习笔记----WebConfig常用配置节点介绍
一.配置文件入门 .Net提供了一种保存项目配置信息的办法,就是利用配置文件,配置文件的后缀一般是.config.在WinForm程序中配置文件一般是App.config.在Asp.net中一般默认是 ...
- logback logback.xml常用配置详解(三)
logback logback.xml常用配置详解 <filter> <filter>: 过滤器,执行一个过滤器会有返回个枚举值,即DENY,NEUTRAL,ACCEPT其中之 ...
- JVM 常用配置
JVM的配置,最常用的两个配置就是:-Xms512m –Xmx1024m -Xms设置JVM的初始化内存大小,-Xmx为最大内存大小,当突破这个值,将会报内存溢出,导致的原因有很多,主要是虚拟机的回收 ...
随机推荐
- linux下启动springboot服务
错误日志 SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] . __ ...
- 黄聪:Navicat for MySQL的1577错误解决
今天尝试使用了Windows下的可视化mysql数据库管理工具Navicat,界面清爽,易操作上手,感觉还不错. 不过当连接上mysql后,无论打开任何一个数据库,都会提示:1577 – Cannot ...
- 使用SafeViewFlipper避免ViewFlipper交替时Crash
使用SafeViewFlipper避免ViewFlipper交替时Crash 柳志超博客 » Program » Andriod » 使用SafeViewFlipper避免ViewFlipper交替时 ...
- sort+函数指针、sort+比较器对象、qsort速度比较
一.上代码 #include<bits/stdc++.h> using namespace std; #define MAXN 50000000 struct TS { int a, b, ...
- 三.jQuery源码解析之jQuery的框架图
这张图片是对jQuery源码截图,一点一点拼出来的. 现在根据这张图片来对jQuery框架做一些说明. 一.16~9404行可以发现,最外层是一个自调用函数.当jQuery初始化时,这个自调用函数包含 ...
- 【Codeforces】Codeforces Round #492 (Div. 2) (Contest 996)
题目 传送门:QWQ A:A - Hit the Lottery 分析: 大水题 模拟 代码: #include <bits/stdc++.h> using namespace std; ...
- centos软件安装
首先安装epel,然后再安装yum加速 #centos7下执行以下命令 wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7. ...
- django-form.errors和前端上传文件
一.上传文件: 在相应的模型里面定义`FileField`或者是`ImageField`类型的字段,并且1.设置好`upload_to`参数来指定上传的路径. class User(models.Mo ...
- Firemonkey Button 颜色
delphi FMX Firemonkey Button 按钮 颜色 TintColor 颜色 Button1.TintColor:=TAlphaColorRec.Green;
- 史上最全的Maven Pom文件标签详解
<span style="padding:0px; margin:0px"><project xmlns="http://maven.apache.or ...