handsontable自定义渲染
来源:互联网 发布:淘宝评价怎么取消隐藏 编辑:程序博客网 时间:2024/05/17 21:57
hansontable的渲染定义方式有多种,常见的有NumericRenderer、TextRenderer、CheckboxRenderer,但他们都是通过registerRenderer来渲染的,registerRenderer是hansontable的渲染公用方法,其他的渲染都是在此基础上扩展的。
那么我们需要自定义一个文本渲染该如何实现呢?请跟我来:
首先需要定义你自己的渲染方法
var MyRenderer = function (instance, td, row, col, prop, value, cellProperties) { Handsontable.renderers.TextRenderer.apply(this, arguments); $(td).css("text-align", cel[k].align); $(td).css("vertical-align", cel[k].valign); });
这里的instance是hansontable的核心方法接口对象,td是一个渲染的单元格,value是单元格的值,cellProperties是单元格的渲染方法对象,其中包含一个renderer属性,定义了该用那种渲染方式。
Handsontable.renderers.TextRenderer.apply(this, arguments);
这句话不可少。其含义是将自定义方法中的配置信息通过hansontable的Text渲染应用到当前window对象上。this表示当前window对象,arguments表示渲染方法中的7个参数,是一个参数数组。
在单元格属性配置中调用自定义的渲染方法
cells: function (row, col, prop) { var cellProperties = {}; if (row === 0 || this.instance.getData()[row][col] === 'readOnly') { cellProperties.readOnly = true; } if (row === 0) { cellProperties.renderer = firstRowRenderer;//调用首行渲染方法 } else { cellProperties.renderer = MyRenderer;//调用自定义渲染方法 } return cellProperties; }
或者直接在cells中调用renderer属性
cells: function(row, col, prop) {this.renderer = myRenderer;}
这样就能使用自定义的渲染方法了。
为hansontable中的元素添加事件。
Handsontable.Dom.removeEvent(document, eventName, function(){});Handsontable.Dom.addEvent(document, eventName, function(){});document是dom元素,eventName是事件名,function(){}是事件处理函数。
0 0
- handsontable自定义渲染
- Handsontable
- Handsontable
- handsontable测试
- 自定义渲染器
- 自定义View实现渲染
- OGRE自定义渲染循环实现
- OGRE自定义渲染循环实现
- 自定义动画渲染器 Interceptor
- 十、WorldWindJava+自定义渲染类
- handsontable 的使用方法
- handsontable的核心方法
- handsontable插件事件
- Handsontable通用方法
- handsontable创建测试数据
- HandsonTable封装构思
- handsontable日期控件汉化
- Handsontable对单元格的操作
- 找出数列单独的数字
- 给ASP.NET MVC及WebApi添加路由优先级
- 【网络】(十二)UDP简介
- 网络IO之阻塞、非阻塞、同步、异步总结
- 概率论
- handsontable自定义渲染
- icloud之部署架构
- Acdream 1061 郭式树
- 疯狂猜歌实现(8)—— 实现答案判断逻辑
- Enable multithreading to use std::thread: Operation not permitted
- iOS--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开发汇总
- IO - 同步,异步,阻塞,非阻塞 (亡羊补牢篇)
- 24v转12v芯片
- 致PHP路上的“年轻人”