Extjs Grid Cell Tooltip

Ext.tip.QuickTipManager.init();

Ext.onReady(function(){

Ext.create(‘Ext.data.Store‘, {

storeId:‘simpsonsStore‘,

fields:[‘name‘, ‘email‘, ‘phone‘],

data:{‘items‘:[

{ ‘name‘: ‘Lisa‘,  "email":"[email protected]",  "phone":"555-111-1224"  },

{ ‘name‘: ‘Bart‘,  "email":"[email protected]",  "phone":"555-222-1234" },

{ ‘name‘: ‘Homer‘, "email":"[email protected]",  "phone":"555-222-1244"  },

{ ‘name‘: ‘Marge‘, "email":"[email protected]", "phone":"555-222-1254"  }

]},

proxy: {

type: ‘memory‘,

reader: {

type: ‘json‘,

root: ‘items‘

}

}

});

Ext.create(‘Ext.grid.Panel‘, {

title: ‘Simpsons‘,

store: Ext.data.StoreManager.lookup(‘simpsonsStore‘),

columns: [

{ text: ‘Name‘,  dataIndex: ‘name‘ },

{ text: ‘Email‘, dataIndex: ‘email‘, flex: 1 },

{ text: ‘Phone‘, dataIndex: ‘phone‘ }

],

height: 200,

width: 400,

renderTo: Ext.getBody()

, listeners: {

viewready: function (grid) {

var view = grid.view;

// record the current cellIndex

grid.mon(view, {

uievent: function (type, view, cell, recordIndex, cellIndex, e) {

grid.cellIndex = cellIndex;

grid.recordIndex = recordIndex;

}

});

grid.tip = Ext.create(‘Ext.tip.ToolTip‘, {

target: view.el,

delegate: ‘.x-grid-cell‘,

trackMouse: true,

renderTo: Ext.getBody(),

listeners: {

beforeshow: function updateTipBody(tip) {

if (!Ext.isEmpty(grid.cellIndex) && grid.cellIndex !== -1) {

header = grid.headerCt.getGridColumns()[grid.cellIndex];

tip.update(grid.getStore().getAt(grid.recordIndex).get(header.dataIndex));

}

}

}

});

}

}

});

Ext.create(‘Ext.data.Store‘, {

storeId:‘employeeStore‘,

fields:[‘firstname‘, ‘lastname‘, ‘seniority‘, ‘dep‘, ‘hired‘],

data:[

{firstname:"Michael", lastname:"Scott", seniority:7, dep:"Management", hired:"01/10/2004"},

{firstname:"Dwight", lastname:"Schrute", seniority:2, dep:"Sales", hired:"04/01/2004"},

{firstname:"Jim", lastname:"Halpert", seniority:3, dep:"Sales", hired:"02/22/2006"},

{firstname:"Kevin", lastname:"Malone", seniority:4, dep:"Accounting", hired:"06/10/2007"},

{firstname:"Angela", lastname:"Martin", seniority:5, dep:"Accounting", hired:"10/21/2008"}

]

});

Ext.create(‘Ext.grid.Panel‘, {

title: ‘Column Demo‘,

store: Ext.data.StoreManager.lookup(‘employeeStore‘),

columns: [

{text: ‘First Name‘,  dataIndex:‘firstname‘},

{text: ‘Last Name‘,  dataIndex:‘lastname‘},

{text: ‘Hired Month‘,  dataIndex:‘hired‘, xtype:‘datecolumn‘, format:‘M‘},

{text: ‘Department (Yrs)‘, xtype:‘templatecolumn‘, tpl:‘{dep} ({seniority})‘}

],

width: 400,

forceFit: true,

renderTo: Ext.getBody()

, listeners: {

viewready: function (grid) {

var view = grid.view;

// record the current cellIndex

grid.mon(view, {

uievent: function (type, view, cell, recordIndex, cellIndex, e) {

grid.cellIndex = cellIndex;

grid.recordIndex = recordIndex;

}

});

grid.tip = Ext.create(‘Ext.tip.ToolTip‘, {

target: view.el,

delegate: ‘.x-grid-cell‘,

trackMouse: true,

renderTo: Ext.getBody(),

listeners: {

beforeshow: function updateTipBody(tip) {

if (!Ext.isEmpty(grid.cellIndex) && grid.cellIndex !== -1) {

var header = grid.headerCt.getGridColumns()[grid.cellIndex];

var val = grid.getStore().getAt(grid.recordIndex).get(header.dataIndex);

var isDateColumn = header.xtype == ‘datecolumn‘;

tip.update(isDateColumn ? Ext.util.Format.date(val, header.format) : val);

}

}

}

});

}

}

});

});

时间: 2024-08-28 11:36:58

Extjs Grid Cell Tooltip的相关文章

ExtJS Grid 获得选中项数据

ExtJS Grid 获得选中项数据 - hwq1987的专栏 - 博客频道 - CSDN.NET Grid的数据源是store,我们有时需要做点击某一个项而触发一定的事件,在这个处理过程中,我们不免需要得到点击的那个项,如何获得相应的数据呢? 首先,来看看怎么写触发事件.假设变量_grid就是一个GridPanel的句柄(或者说引用),我们要对实现双击GridPanel中的某一项时触发一个event.那么我们只需要 _grid.addListener('celldblclick',functi

ExtJS Grid 字段因为json数值前空格加载失败

今天遇到个奇葩问题,因为EXCLE数据没有去掉前空格导入之后EXTJS.Grid无法加载数据. 排错顺序: 首先检查控制台有没有报错. 在oracle中运行sql语句,检查SQL是否正确 导出json数据,并在在线json验证中验证json数据是否正确. 在上线后,当天显示正常,并进行过导出操作.怀疑近期数据出错.添加createdate筛选条件,从当天到前天倒序检查是否报错. 当天数据报错,前天数据无错.检查当天数据. 找到当天数据,检查中发现5列中文长度过长,怀疑这些列中数据有特殊字符,一列

ExtJS Grid Column Number

 {                 xtype: 'numbercolumn',                 text: '亏盈数量',                 width: 130,                 dataIndex: 'LossOrProfitNum',                 editor: {                     xtype: 'numberfield',                     minValue: 0,    

Extjs grid分页多选记忆功能

很多同事在用extjs grid做分页的时候,往往会想用grid的多选功能来实现导出Excel之类的功能(也就是所谓的多选记忆功能),但在选选择下一页的时候 上一页选中的已经清除 这是因为做分页的时候又向服务器请求了分页数据 以下解决方法是在工作中的碰到的.分享给大家共同学习一下. 1.首先定义一个保存选中记录的集合 2.定义选中记录的CheckboxModel 3.定义store(这个请参考) 监听beforeload 及load事件 4.在grid中引用sm

Extjs grid 遍历store

var projectMemberGrid = Ext.getCmp("projectMemberGrid"); var selFuns = []; projectMemberGrid.store.each(function(rec){ selFuns.push(Ext.encode(rec.data)); });Extjs grid 遍历store

extjs grid renderer用法

extjs grid renderer用法 摘自:http://www.cnblogs.com/ljian/archive/2011/10/27/2226959.html var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer({ header: "", width: 20, align: 'center' }),{ header: '', align: 'center', dataIndex: 'AccountAndRo

extjs grid数据改变后刷新的实现

做了一个编辑extjs grid记录的窗体,但更改数据后,怎么重新刷新grid让数据显示呢? 做了半天的尝试,其实到最后只需一句话,faint:-) this.store.reload(); 不用加任何参加都可以了:-) extjs grid数据改变后刷新的实现

extjs grid 复制问题另一种解决方案.

之前的项目中虽然也经常使用到extjs,但或许是没有注意到,也或许是根本就没有需要用到这个功能. 前几天在和客户讨论需求时,客户说想要能够将gird表中的数据复制出来,当时没多想,感觉这功能extjs应该是支持的,应该配置一个后几个参数就能搞定的吧.可是回来后查extjs的api才发现好像根本就没有这个设置的.再回想之前的项目中,好像确实没有做过这个功能.所以赶紧就到网上找了,也找个来一些解决方案,但感觉实现起来比较麻烦,也没去试. 今天再想到这个问题时,突然一个想法在脑海中闪现,应该能够借用g

ExtJs Grid 删除,编辑,查看详细等超链接处理

在网上查了好多资料,关于ExtJs处理操作栏的“删除”.“编辑”.“查看详细”的处理,原来项目都是这么处理: 操作栏:{ text:'操作', xtype:'actioncolumn', items : [{ icon : '../images/edit.png', tooltip : '编辑', handler:function(grid, rowIndex, colIndex){ var record = grid.getStore().getAt(rowIndex); var data =