renderer

展示的数据不是来自于数据源,而是先把DOM和其他信息传给renderer,然后展示。

//五种展示函数
TextRenderer: default
NumericRenderer
AutocompleteRenderer
CheckboxRenderer
PasswordRenderer

自己不能给cell加listener的原因:1、一个cell会多次调用renderer,可能会导致它有多个相同事件监听器;2、cell CRUD scrolling,可能导致cell和listener绑定错误。如果一定要这样做,需要把cell content放在div中,给div加监听器

renderer函数 尽可能的快和简洁

editor

validator

可以是函数或者regex;与renderer和editor相比,validator不需要为每个元素都定义。

renderer,editor,validator是相互联系的

handsontable定义了一些type,来系列化这三个函数,好处如下:

var hot = new Handsontable(document.getElementById('container'), {
columns: [
{
renderer: Handsontable.NumericRenderer,
editor: Handsontable.editors.TextEditor,
validator: Handsontable.NumericValidator
}
]
}); var hot = new Handsontable(document.getElementById('container'), {
columns: [
{
type: 'numeric'
}
]
});

预定义的类型

text
numeric
date
checkbox
password
select
dropdown
autocomplete
handsontable
//function的优先级高于type
var hot = new Handsontable(document.getElementById('container'), {
columns: [
{
type: 'numeric',
validator: customValidator // validator function defined elsewhere
}
]
});
//type='password'没有定义validator,比函数更特殊。
var hot = new Handsontable(document.getElementById('container'), {
validator: customValidator, // validator function defined elsewhere
columns: [
{
type: 'password'
},
{}
]
});
相当于
var hot = new Handsontable(document.getElementById('container'), {
columns: [
{
renderer: Handsontable.PasswordRenderer,
editor: Handsontable.editors.PasswordEditor,
validator: undefined
}
{
renderer: Handsontable.TextRenderer, // text cell type is the default one
editor: Handsontable.editors.TextEditor, // text cell type is the default one
validator: customValidator
}
]
});
//通过function定义的才可以,如果通过type定义的,则返回undefined
var cellProperties = $('#container').handsontable('getCellMeta', 0, 0);
// get cell properties for cell [0, 0]
cellProperties.renderer; // get cell renderer
cellProperties.editor; // get cell editor
cellProperties.validator; // get cell validator
//通过function或者type定义的都可以
getCellRenderer(row, col)
getCellEditor(row, col)
getCellValidator(row, col)

  

handsontable-developer guide-cell function的更多相关文章

  1. Intel® Threading Building Blocks (Intel® TBB) Developer Guide 中文 Parallelizing Data Flow and Dependence Graphs并行化data flow和依赖图

    https://www.threadingbuildingblocks.org/docs/help/index.htm Parallelizing Data Flow and Dependency G ...

  2. 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 ...

  3. 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 ...

  4. Ehcache(2.9.x) - API Developer Guide, Searching a Cache

    About Searching The Search API allows you to execute arbitrarily complex queries against caches. The ...

  5. 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 ...

  6. Ehcache(2.9.x) - API Developer Guide, Cache Eviction Algorithms

    About Cache Eviction Algorithms A cache eviction algorithm is a way of deciding which element to evi ...

  7. 移动端目标识别(2)——使用TENSORFLOW LITE将TENSORFLOW模型部署到移动端(SSD)之TF Lite Developer Guide

    TF Lite开发人员指南 目录: 1 选择一个模型 使用一个预训练模型 使用自己的数据集重新训练inception-V3,MovileNet 训练自己的模型 2 转换模型格式 转换tf.GraphD ...

  8. Ehcache(2.9.x) - API Developer Guide, Basic Caching

    Creating a CacheManager All usages of the Ehcache API start with the creation of a CacheManager. The ...

  9. Ehcache(2.9.x) - API Developer Guide, Using Explicit Locking

    About Explicit Locking Ehcache contains an implementation which provides for explicit locking, using ...

  10. Ehcache(2.9.x) - API Developer Guide, Blocking and Self Populating Caches

    About Blocking and Self-Populating Caches The net.sf.ehcache.constructs package contains some applie ...

随机推荐

  1. Android中如何使用JUnit进行单元测试 eclipse

    Android中如何使用JUnit进行单元测试 在我们日常开发android app的时候,需要不断地进行测试,所以使用JUnit测试框架显得格外重要,学会JUnit可以加快应用的开发周期. Andr ...

  2. requests and BeautifulSoup

    requests Python标准库中提供了:urllib.urllib2.httplib等模块以供Http请求,但是,它的 API 太渣了.它是为另一个时代.另一个互联网所创建的.它需要巨量的工作, ...

  3. django-模板,过滤器

    for…in…:跟python中的for…in…是一样的用法 {% for m in modules %} {{ forloop.cpunter }} {{ m }} {% end %} forloo ...

  4. 原生态Vim使用快捷键

    我的第一篇博客,凌晨2点加班不想睡,随便写点.本人菜鸟一个,努力学习,争取成为大神.. 第一篇写点什么东西呢,我目前是搞运维的,俗话说"工欲善其事必先利其器",Vim作为最基本的工 ...

  5. Rhythmk 学习 Hibernate 02 - Hibernate 之 瞬时状态 离线状态 持久化状态 三状态

    by:rhythmk.cnblogs.com 1.Hibernate 三种状态: 1.1.三种定义(个人理解,不一定准确):  瞬时状态(transient):    不被session接管,且不存在 ...

  6. FoxPro 打开文件及使用SQL查询

    set exclusive off OPEN DATABASE t:\tpswin\comp1\time.dbc SHARED select empl_no,date,in, bout, bin, o ...

  7. 一劳永逸解决VLC播放中文字幕乱码问题

    VLC对于Mac/Ubuntu用户来说算得上是必备软件.其相当于PC机上的“暴风影音”,但Mac/Ubuntu的新手使用VLC播放avi时都会碰 到字幕乱码的问题.avi字幕的格式有多种,这里假设你使 ...

  8. XML解析的二种方法之Sax解析

    package com.huawei.xml; import java.io.InputStream;import java.util.Stack; import javax.xml.parsers. ...

  9. manjaro 下golang protobuf的使用

    1.下载protobuf compiler sudo pacman -S protobuf 2.添加环境变量GOBIN export GOBIN=~/go/bin 3.下载golang依赖的包 go ...

  10. python中os.system()的返回值

    [python中os.system()的返回值] 如果第三方程序返回的是布尔型返回值,os.system会将true转为1,false转为0进行返回. 问题: /bin/xxx.py是一个返回码为1的 ...