handsontable-cell features

数据验证:在columns中设置validator,进行同步或异步验证,还可添加beforeValidate, afterValidate函数,allowInvalid:true可以不用验证

var people = [
      {id: 1, name: {first: ‘Joe‘, last: ‘Fabiano‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 2, name: {first: ‘Fred‘, last: ‘Wecler‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 3, name: {first: ‘Steve‘, last: ‘Wilson‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 4, name: {first: ‘Maria‘, last: ‘Fernandez‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 5, name: {first: ‘Pierre‘, last: ‘Barbault‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 6, name: {first: ‘Nancy‘, last: ‘Moore‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 7, name: {first: ‘Barbara‘, last: ‘MacDonald‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 8, name: {first: ‘Wilma‘, last: ‘Williams‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 9, name: {first: ‘Sasha‘, last: ‘Silver‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘},
      {id: 10, name: {first: ‘Don‘, last: ‘Pérignon‘}, ip: ‘0.0.0.1‘, email: ‘Don.Pé[email protected]‘},
      {id: 11, name: {first: ‘Aaron‘, last: ‘Kinley‘}, ip: ‘0.0.0.1‘, email: ‘[email protected]‘}
    ],
    example1 = document.getElementById(‘example1‘),
    example1console = document.getElementById(‘example1console‘),
    settings1,
    ipValidatorRegexp,
    emailValidator;

  ipValidatorRegexp = /^(?:\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|null)$/;
  emailValidator = function (value, callback) {
    setTimeout(function(){    //还能这样验证
      if (/[email protected]+/.test(value)) {
        callback(true);
      }
      else {
        callback(false);
      }
    }, 1000);
  };

  settings1 = {
    data: people,  //hooks
    beforeChange: function (changes, source) {    //changes是数组,数组的元素也是数组,包含四个属性0:10,1:‘name.last‘,2:‘Kinley‘,3:‘foo‘
      for (var i = changes.length - 1; i >= 0; i--) {
        // gently don‘t accept the word "foo" (remove the change at index i)     //如果想改为foo,会把这次修改删掉
        if (changes[i][3] === ‘foo‘) {
          changes.splice(i, 1);
        }
        // if any of pasted cells contains the word "nuke", reject the whole paste     //如果想改为nuke,只是拒绝,而不会删除此次修改
        else if (changes[i][3] === ‘nuke‘) {
          return false;
        }
        // capitalise first letter in column 1 and 2
        else if ((changes[i][1] === ‘name.first‘ || changes[i][1] === ‘name.last‘) && changes[i][3].charAt(0)) {
          changes[i][3] = changes[i][3].charAt(0).toUpperCase() + changes[i][3].slice(1);
        }
      }
    },
    afterChange: function (changes, source) {
      if (source !== ‘loadData‘) {
        example1console.innerText = JSON.stringify(changes);
      }
    },
    colHeaders: [‘ID‘, ‘First name‘, ‘Last name‘, ‘IP‘, ‘E-mail‘],
    columns: [
      {data: ‘id‘, type: ‘numeric‘},
      {data: ‘name.first‘},
      {data: ‘name.last‘},    //给ip加事件处理程序,可以不通过验证
      {data: ‘ip‘, validator: ipValidatorRegexp, allowInvalid: true},
      {data: ‘email‘, validator: emailValidator, allowInvalid: false}
    ]
  };
  var hot = new Handsontable(example1, settings1);

  

时间: 2024-10-25 01:48:11

handsontable-cell features的相关文章

handsontable

---恢复内容开始--- 很像excel的jquery插件.关于它的中文资料不多,自己只能看看英文的了.记录如下: 数据绑定: 1.更新局部数据,需要使用render方法: 2.如果引用的数据是:JSON.parse(JSON.stringify(data2)),则不会被更改 3.保存之前clone表格,使用afterChange的var tmpData = JSON.parse(JSON.stringify(data3));语句. 数据源: 1.数组 2.隐藏第二列 load and save

8 Great Java 8 Features No One's Talking about--转载

原文地址:http://www.infoq.com/articles/Java-8-Quiet-Features If you haven’t seen some of the videos or tutorials around Java 8, you’ve probably been super-busy or have a more interesting social life than I do (which isn’t saying much). With new features

Dynamic Table View Cell Height and Auto Layout(转)

11/23/2014: Updated to be compatible with iOS 7, iOS 8, and Xcode 6.1. If you wanted to create a customized table view complete with dynamic table view cell height in the past, you had to write a lot of sizing code. You had to calculate the height of

Handsontable对单元格的操作

1.自动填充单元格数据 fillHandle:true/false    //当值为true时,允许拖动单元格右下角,将其值自动填充到选中的单元格 2.合并单元格 mergeCells:[{row:起始行数,cols:起始列数,rowspan:合并的行数,colspan:合并的列数},...] 3.初始化单元格或列的对齐方式 水平样式:htLeft,htCenter,htRight,htJustify 垂直样式:htTop,htMiddle,htBottom 4.只读模式 列只读,设置列属性:r

Handsontable 学习笔记-Methods

Handson: 亲自实践 先给出数据源和基本配置: var data =[ ["A1","B1","C1","D1"], ["A2","B2","C2","D2"], ["A3","B3","C3","D3"] ]; var objectData = [ {id: 1

Real-Time Human Detection using Relational Depth Similarity Features

Real-Time Human Detection using Relational Depth Similarity Features 本文是论文笔记. 转载请注明:http://blog.csdn.net/stdcoutzyx/article/details/40299191 本文使用TOF摄像头采集到的图像里有深度信息的特点,提出了一种新的深度相关的相似度特征(RDSF)来检测行人.同时,利用深度信息,可以判断人员遮挡的情况,将这种情况考虑进算法,可以同时提升Hog与RDSF的效果. 1

codeforces Looksery Cup 2015 D. Haar Features

The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model

文献导读 - Machine Learning Identifies Stemness Features Associated with Oncogenic Dedifferentiation

参考: Machine Learning Identifies Stemness Features Associated with Oncogenic Dedifferentiation 前所未有!10篇<Cell>文章及封面聚焦人类伟大成就:癌症基因组图谱TCGA!改写教科书式突破! “癌症大地图”(Pan-Cancer Atlas) 肿瘤界“巅峰之作”:美国推出“泛癌症图谱”服务全人类 文章代码: PanCanStem 文档 相关培训: 待续~ 原文地址:https://www.cnblo

怎样让自定义Cell的图片和文本自适应高度

Let's do it! 首先创建一个Model类 包括一个图片名称属性 还有文字内容属性 #import <Foundation/Foundation.h> @interface Model : NSObject @property (nonatomic, copy) NSString *imageName; @property (nonatomic, copy) NSString *info; @end 创建一个继承于UITableViewCell的MyTableViewCell,把模型作

UI_11 自定义UITableViewCell、Cell的高度自适应

UITableViewCell很难满足我们的需求,因此,CustomCell(自定义单元格)至关重要.下面将通过一个例子演示自定义Cell.第二部分演示根据文本内容自适应Label.Cell高度. 第一部分 CustomCell的创建 1.创建DemoTableViewController,继承自UITableViewController,并设置其为window的根视图 AppDelegate.m - (BOOL)application:(UIApplication *)application