javascript - 在渲染时隐藏检查单元 - extjs 6.5.3 现代
问题描述
如果另一个值是,我试图隐藏checkcell
a 。但不幸的是,根据sencha 文档,只有当单元格类型是 Ext.grid.cell.Cell 的默认值时才会处理此配置。checkcolumn
column
null
所以renderer
配置的解决方案将不起作用。
例如:
{
xtype: 'checkcolumn',
dataIndex: 'isSomething',
text: '',
width: 30,
menuDisabled: true,
headerCheckbox: false,
renderer: function(value, record) {
var relatedValue = record.get('somethingElse');
return relatedValue ? new Ext.grid.column.Check().renderer(value) : '';
}
}
有什么提示或技巧可以做到这一点?
解决方案
您可以使用gridcell
并且可以在内部gridcell
使用checkbox
来实现您的要求。
在这个FIDDLE中,我使用gridcell
and创建了一个演示checkbox
。我希望这将帮助/指导您实现您的要求。
代码片段
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create({
xtype: 'grid',
title: 'Tree Grid Demo',
// itemConfig: {
// viewModel: true
// },
store: {
fields: [{
name: 'isCheck',
defaultValue: true
}],
data: [{
firstname: "Michael",
lastname: "Scott",
seniority: 7,
department: "Management",
hired: "01/10/2004"
}, {
firstname: "Dwight",
lastname: "Schrute",
seniority: 2,
department: "Sales",
hired: "04/01/2004"
}, {
firstname: "Jim",
lastname: "Halpert",
seniority: 3,
department: "Sales",
hired: "02/22/2006"
}, {
firstname: "Kevin",
lastname: "Malone",
seniority: 4,
department: '',
hired: "06/10/2007"
}, {
firstname: "Angela",
lastname: "Martin",
seniority: 5,
department: "Accounting",
hired: "10/21/2008"
}]
},
columns: [{
text: 'First Name',
dataIndex: 'firstname'
}, {
text: 'Last Name',
dataIndex: 'lastname'
}, {
text: 'Hired Month',
dataIndex: 'hired'
}, {
text: '',
width: 30,
renderer: function (value, record, index, cell) {
if (record.get('department')) {
cell.setTools({
xtype: 'checkbox',
checked: record.get('isCheck')
});
} else {
return '';
}
}
/*cell: {
tools: {
xtype: 'checkbox',
bind: {
hidden: '{!record.department}',
checked: '{record.isCheck}'
}
}
}*/
}],
fullscreen: true
});
}
});
推荐阅读
- recursion - Prolog递归基本案例
- javascript - 为按钮列表中的一个按钮切换类名
- python - 如何为 Altair 生成的图表添加字幕
- sql - 在查询中使用子查询返回不带变量的结果
- c - 有没有办法遍历多个结构,比如通过数组?
- typescript - TypeScript 从使用的参数推断返回类型
- visual-studio - 在 Azure Pipeline 中的 C# 项目上测试 NuGet 包安装
- arrays - 如何按类别列出对象数组中的项目,并仅根据上次迭代的类别呈现组件
- node.js - 导入具有导出枚举的模块时找不到模块错误
- encryption - GCP 中的客户敏感数据加密(GCS、BQ...)