extjs工具提示获取单元格索引
我使用此代码在网格的每一行上显示自定义工具提示。问题是我只能在某些列上显示它。如何在beforeshow事件中检索cellIndex? 我试过使用tipp.triggerement.cellIndex和tipp.anchoreElement.cellIndex,但没有定义extjs工具提示获取单元格索引,extjs,grid,tooltip,Extjs,Grid,Tooltip,我使用此代码在网格的每一行上显示自定义工具提示。问题是我只能在某些列上显示它。如何在beforeshow事件中检索cellIndex? 我试过使用tipp.triggerement.cellIndex和tipp.anchoreElement.cellIndex,但没有定义 var tip = Ext.create('Ext.tip.ToolTip', { // The overall target element. target: grid.el, // Each grid row
var tip = Ext.create('Ext.tip.ToolTip', {
// The overall target element.
target: grid.el,
// Each grid row causes its own separate show and hide.
delegate: grid.view.cellSelector,
// Moving within the row should not hide the tip.
trackMouse: true,
// Render immediately so that tip.body can be referenced prior to the first show.
renderTo: Ext.getBody(),
listeners: {
// Change content dynamically depending on which element triggered the show.
beforeshow: function updateTipBody(tipp) {
}
}
})) 首先在网格上放置一个配置
selType:'cellmodel',
通过这样做,您可以使用下面的代码获得所选单元格的当前位置
grid.getSelectionModel().getCurrentPosition()代码>
这将重新运行当前的行和列详细信息以及一些其他详细信息,因此您需要在tip的“显示前”事件中访问此数据,并返回false,您无需显示它。首先在网格上放置一个配置selType:“cellmodel”,
通过这样做,您可以使用以下代码获取所选单元格的当前位置
grid.getSelectionModel().getCurrentPosition()代码>
这将重新运行当前的行和列详细信息以及一些其他详细信息,因此您需要在tip的“显示前”事件中访问此数据,并返回false,您无需显示它。尝试以下操作:
Ext.create('Ext.grid.Panel', {
listeners:{
render:function(grid) {
var view=grid.getView();
view.tip = Ext.create('Ext.tip.ToolTip', {
target: grid.el,
// this gets css query to identify the individual cells
delegate: view.cellSelector,
listeners: {
beforeshow: function(tip) {
var column = view.getGridColumns()[tip.triggerElement.cellIndex];
var record = view.getRecord(tip.triggerElement.parentNode);
tip.update(record.get(column.dataIndex));
}
}
});
}
}
);
试试这个:
Ext.create('Ext.grid.Panel', {
listeners:{
render:function(grid) {
var view=grid.getView();
view.tip = Ext.create('Ext.tip.ToolTip', {
target: grid.el,
// this gets css query to identify the individual cells
delegate: view.cellSelector,
listeners: {
beforeshow: function(tip) {
var column = view.getGridColumns()[tip.triggerElement.cellIndex];
var record = view.getRecord(tip.triggerElement.parentNode);
tip.update(record.get(column.dataIndex));
}
}
});
}
}
);
当我希望(onmouseover)在工具提示中显示单元格/列的内容(例如,内容长于单元格的宽度)时,我使用以下渲染器方法,您可以使用所需的值来适应您的情况:
renderer: function (value, metaData, record, rowIndex, colIndex, store, view) {
metaData.tdAttr = 'data-qtip= "' + value + '" data-qclass="tipCls" ';
return value;
}
在我的情况下效果很好,而且很简单
请看:当我希望(onmouseover)在工具提示中显示单元格/列的内容(例如,内容长于单元格的宽度)时,我使用以下渲染器方法,您可以使用所需的值来适应您的情况:
renderer: function (value, metaData, record, rowIndex, colIndex, store, view) {
metaData.tdAttr = 'data-qtip= "' + value + '" data-qclass="tipCls" ';
return value;
}
在我的情况下效果很好,而且很简单
看看:我已经试过了,但是我得到了提示。triggerElement.cellIndex是未定义的,我必须将selType:'cellmodel'
添加到网格中,现在它可以工作了。多亏了你和@surya prakash tummaI,我已经尝试过了,但我得到了提示。Triggerement.cellIndex是未定义的,我必须将selType:'cellmodel'
添加到网格中,现在它可以工作了。感谢您和@surya prakash tummaI,我已经尝试过了,但是我的工具提示是html格式的,我无法使用渲染器函数获得相同的结果。我认为它不接受数据qtip属性中的html和css标记查看第一个标注提示:这(剑式回答;复制是要摆弄的代码):我已经尝试过了,但我的工具提示是html格式的,我无法使用渲染器功能获得相同的结果。我认为它不接受数据qtip属性中的html和css标记查看第一个调出提示:这(剑回答;复制是要摆弄的代码):我没有定义,你能链接我你在哪里找到getCurrentPosition方法的?我在房间里找不到它。如果是Ext js 5或更高版本,则使用getPosition方法我没有定义,请将getCurrentPosition方法链接到哪里?我在房间里找不到它。如果是Ext js 5或更高版本,请使用getPosition方法