ExtJS Grid 每个Cell都显示tooltip
来源:互联网 发布:软件原型设计 编辑:程序博客网 时间:2024/06/10 03:15
在Ext JS 3.x 中,如果为GridPanel中的每个Cell都显示tooltip时,而内容是就Cell内容时,有一种比较好的方法就是官网推荐的【Ext JS 3.x\src\widgets\tips\ToopTip.js】中的第90行到108行的例子,如下所示
- var myGrid = new Ext.grid.GridPanel(gridConfig);
- myGrid.on('render', function(grid) {
- var store = grid.getStore(); // Capture the Store.
- var view = grid.getView(); // Capture the GridView.
- myGrid.tip = new Ext.ToolTip({
- target: view.mainBody, // The overall target element.
- delegate: '.x-grid3-row', // Each grid row causes its own seperate show and hide.
- trackMouse: true, // Moving within the row should not hide the tip.
- renderTo: document.body, // Render immediately so that tip.body can be
- // referenced prior to the first show.
- listeners: { // Change content dynamically depending on which element
- // triggered the show.
- beforeshow: function updateTipBody(tip) {
- var rowIndex = view.findRowIndex(tip.triggerElement);
- tip.body.dom.innerHTML = 'Over Record ID ' + store.getAt(rowIndex).id;
- }
- }
- });
- });
然而这个例子,只限于显示row,而不适合cell,当我们仿照取列数时
- var cellIndex = view.findCellIndex(tip.triggerElement);
这时总会返回一个false,于是就到不得Cell对象或内容。经过一段时间的摸索,终于找到的原因,原来上面指定delegate属性为row, 我们只需要改成
- delegate: '.x-grid3-cell',
这样我就到得Cell对象,显示tooltip就小事一桩,给个例子供大家参考
- listeners : {
- scope : this,
- render: function (grid){
- //var store = grid.getStore(); // Capture the Store.
- var view = grid.getView(); // Capture the GridView.
- grid.tip = new Ext.ToolTip({
- target: view.mainBody, // The overall target element.
- delegate: '.x-grid3-cell', // Each grid row causes its own seperate show and hide.
- trackMouse: true, // Moving within the row should not hide the tip.
- renderTo: document.body, // Render immediately so that tip.body can be
- anchor: 'top',
- listeners: { // Change content dynamically depending on which element
- // triggered the show.
- beforeshow: function updateTipBody(tip) {
- var rowIndex = view.findRowIndex(tip.triggerElement);
- var cellIndex = view.findCellIndex(tip.triggerElement);
- //前三列或大于第八列内容不提示
- if(cellIndex < 3 || cellIndex >8)return false;
- var cell = view.getCell(rowIndex, cellIndex);
- tip.body.dom.innerHTML = cell.innerHTML;
- }
- }
- });
- }
- }
这时监听只要放在grid中就可以达到效果。
如果你的Cell中不是原始的数据,包括编辑框、颜色、图片等,显示时就不是理想的效果,自己可根据实际情况自行过滤。
0 0
- ExtJS Grid 每个Cell都显示tooltip
- ExtJS Grid 每个Cell都显示tooltip
- ExtJS Grid Tooltip
- ExtJS Grid Tooltip
- Extjs Grid 中的 ToolTip效果
- extjs怎么往grid的每个cell中添加 radio单选按钮
- ExtJS Grid Tooltip的实现方式
- ExtJS Grid Tooltip提示 鼠标悬停
- vaddin grid实现每个单元格的ToolTip(鼠标放在单元格显示出单元格的内容)
- 获取ExtjS grid 单元格cell的值
- ExtJS Grid Tooltip的3+1种实现方式总结
- ExtJS Grid tooltip的几种实现方式
- Extjs 给 Grid 加上tooltip的几种实现方式
- ExtJS Grid Tooltip的3+1种实现方式总结
- ExtJS Grid Tooltip提示 鼠标悬停 项目案例
- extjs grid 不显示表头
- extjs显示grid网页线
- struts+extjs grid显示数据
- 计算机中的有符号数和无符号数
- 智能灯之Android控制端
- PHP 杂项函数
- 二维数组、指针、步长
- 官网下载Google Chrome离线安装包
- ExtJS Grid 每个Cell都显示tooltip
- 当Python和R遇上北京二手房(下)
- Servlet与tomcat配置
- 密码学中的珍宝与窃贼
- Leetcode: Best Time to Buy and Sell Stock IV
- IOS_UI_Label
- PhotoView源码分析(3)
- 3Sum Closest
- 收藏的人工智能相关网站