英文:
tooltip function getTip() not working on actioncolumn Extjs 7.X
问题
getTip函数对我不起作用。
我在我的app.json启动函数中初始化了Ext.tip.QuickTipManager.init();
。
我的actioncolumn看起来像这样:
xtype: 'actioncolumn',
getTip: function(value, metadata, record, rowIndex, colIndex, store) {
return "something";
},
flex: 0.75,
style: 'text-align: left;',
width: 25,
align: 'center',
menuDisabled: true,
bind: {
text: '{filename}'
},
items: [
{
handler: function(view, rowIndex, colIndex, item, e, record, row) {
Application.fireEvent("filefunction", view, rowIndex, colIndex, item, e, record, row);
},
getClass: function(v, metadata, r, rowIndex, colIndex, store) {
return "x-far fa-file-alt";
},
iconCls: 'x-far fa-file-alt'
}
]
它根本不调用getTip()函数。我做错了什么?
文档链接:
英文:
The tooltip function getTip is not working for me.
I initialized Ext.tip.QuickTipManager.init();
in my app.json launch function.
My actioncolumn is looking like this:
xtype: 'actioncolumn',
getTip: function(value, metadata, record, rowIndex, colIndex, store) {
return "something";
},
flex: 0.75,
style: 'text-align: left;',
width: 25,
align: 'center',
menuDisabled: true,
bind: {
text: '{filename}'
},
items: [
{
handler: function(view, rowIndex, colIndex, item, e, record, row) {
Application.fireEvent("filefunction", view, rowIndex, colIndex, item, e, record, row);
},
getClass: function(v, metadata, r, rowIndex, colIndex, store) {
return "x-far fa-file-alt";
},
iconCls: 'x-far fa-file-alt'
}
]
It does not call the getTip() function at all. What am i doing wrong?
The docs:
答案1
得分: 2
getTip
函数只有在您的操作列没有items
,只有一个单一的图标时才起作用。例如,像这样修改您的代码会显示工具提示:
{
xtype: 'actioncolumn',
// this works with items, with one icon
getTip: function(value, metadata, record, rowIndex, colIndex, store) {
return "something";
},
iconCls: 'x-far fa-file-alt',
flex: 0.75,
style: 'text-align: left;',
width: 25,
align: 'center',
menuDisabled: true,
bind: {
text: '{filename}'
},
}
如果在操作列中有多个项,您必须为每个项单独定义工具提示。您可以使用tooltip
配置为操作列中的一个项设置工具提示:
{
xtype: 'actioncolumn',
flex: 0.75,
style: 'text-align: left;',
width: 25,
align: 'center',
menuDisabled: true,
bind: {
text: '{filename}'
},
items: [
{
handler: function(view, rowIndex, colIndex, item, e, record, row) {
Application.fireEvent("filefunction", view, rowIndex, colIndex, item, e, record, row);
},
getClass: function(v, metadata, r, rowIndex, colIndex, store) {
return "x-far fa-file-alt";
},
iconCls: 'x-far fa-file-alt',
// add this for fixed tooltip on the item
tooltip: 'something',
}
]
}
这是一个静态工具提示,固定在列中的一个操作上。如果您需要它是动态的,例如根据记录值,您可以为每个项使用getClass
函数来实现:
{
xtype: 'actioncolumn',
flex: 0.75,
style: 'text-align: left;',
width: 25,
align: 'center',
menuDisabled: true,
bind: {
text: '{filename}'
},
items: [
{
handler: function(view, rowIndex, colIndex, item, e, record, row) {
Application.fireEvent("filefunction", view, rowIndex, colIndex, item, e, record, row);
},
getClass: function(v, meta, r, rowIndex, colIndex, store) {
// set dynamic tooltip with these two lines
var tooltip = 'something dynamic';
meta.tdAttr = Ext.String.format('data-qtip="{0}"', tooltip);
return "x-far fa-file-alt";
},
iconCls: 'x-far fa-file-alt'
}
]
}
英文:
The getTip
function will only work if your action column does not have items
, only a single icon. For example, modifying your code like this does display the tooltip:
{
xtype: 'actioncolumn',
// this works with items, with one icon
getTip: function(value, metadata, record, rowIndex, colIndex, store) {
return "something";
},
iconCls: 'x-far fa-file-alt',
flex: 0.75,
style: 'text-align: left;',
width: 25,
align: 'center',
menuDisabled: true,
bind: {
text: '{filename}'
},
}
If you have multiple items in the action column, you have to define tooltip separately for each item. You can set the tooltip for one item in the action column using the tooltip
configuration:
{
xtype: 'actioncolumn',
flex: 0.75,
style: 'text-align: left;',
width: 25,
align: 'center',
menuDisabled: true,
bind: {
text: '{filename}'
},
items: [
{
handler: function(view, rowIndex, colIndex, item, e, record, row) {
Application.fireEvent("filefunction", view, rowIndex, colIndex, item, e, record, row);
},
getClass: function(v, metadata, r, rowIndex, colIndex, store) {
return "x-far fa-file-alt";
},
iconCls: 'x-far fa-file-alt',
// add this for fixed tooltip on the item
tooltip: 'something',
}
]
}
This is a static tooltip, fixed for one action in the column. If you need it dynamic, for example dependant on the record value, you can use the getClass
function for that for each item:
{
xtype: 'actioncolumn',
flex: 0.75,
style: 'text-align: left;',
width: 25,
align: 'center',
menuDisabled: true,
bind: {
text: '{filename}'
},
items: [
{
handler: function(view, rowIndex, colIndex, item, e, record, row) {
Application.fireEvent("filefunction", view, rowIndex, colIndex, item, e, record, row);
},
getClass: function(v, meta, r, rowIndex, colIndex, store) {
// set dynamic tooltip with these two lines
var tooltip = 'something dynamic';
meta.tdAttr = Ext.String.format('data-qtip="{0}"', tooltip);
return "x-far fa-file-alt";
},
iconCls: 'x-far fa-file-alt'
}
]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论