javascript - 如何在 extJS 树形面板中显示图像而不是文本
问题描述
如何在 extJS 树形面板中显示图像而不是文本。
我正在使用拖放特性。我正在使用treeviewdragdrop
方法。
现在我想显示一些图像而不是文本。
这是我的代码。
{
xtype: 'treepanel',
align: 'stretch',
rootVisible : false,
title:'My Tree',
useArrows: true,
hideHeaders: true,
scrollable: true,
autoScroll: true,
loadMask: {
msg: 'Loading'
},
copy: true,
rootVisible: false,
viewConfig: {
plugins: {
ddGroup: 'grid-to-form',
ptype: 'treeviewdragdrop',
appendOnly: true,
sortOnDrop: true,
enableDrag: true,
containerScroll: true,
allowParentInsert: false,
allowContainerDrops: false
}
},
store: Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
"text": ".",
"children": [{
"item": "Box",
"iconCls": "tree-grid-task"
},
{
"item": "Date",
"iconCls": "tree-grid-task"
},
{
"item": "Number",
"iconCls": "tree-grid-task"
},
{
"item": "Text",
"iconCls": "tree-grid-task"
},
{
"item": "Field",
"editable":true
}]
}
}),
columns: [{
xtype: 'treecolumn',
text: '',
dataIndex: 'item',
flex: 2,
sortable: true
}]
}
解决方案
您可以将渲染器放入树列中;我创建了一个小提琴来展示它作为示例。
{
xtype: 'treecolumn',
text: '',
dataIndex: 'item',
flex: 1,
sortable: true,
renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
return '<img width=50 src="' + value + '"></img>';
}
}
推荐阅读
- dart - 无法暂停 Dart 隔离
- spring-boot - 如何在过期事件中访问 Spring Data Redis 存储对象?
- c# - 如何使用同一方法多次刷新父组件中的子组件?
- c++ - 如何指定#include
升压? - c++ - 特定于目录结构的 Makefile
- javascript - 我需要将 manifest.json 文件放在我的网络服务器的根目录吗?
- user-interface - Flutter Stack 和 Card 使用
- nuxt.js - SPA 模式下的 Nuxt.js 静态生成导致与内部加载组件相同的输出
- algorithm - 这个算法的复杂度(Big O)是多少?
- java - 如何在java中调用默认构造函数之前设置变量?