我有一个包含网格的字段集,该网格有3个checkcolumns:Leader,Member和Viewer。如果用户单击Leader checkcolumn中的复选框,则应禁用Member和Viewer复选框中的相应复选框(即用户不能单击这些复选框)。如果用户单击Member或Viewer checkcolumns中的复选框,也是如此;其他复选框不应该是可点击的。任何想法如何去做?
答案 0 :(得分:1)
RadioGroup不可行,因为应用程序需要允许用户检查多个复选框(在一个复选列中)。我已经部分解决了这个问题:现在,如果我单击Leader checkcolumn中的任何复选框,然后单击Viewer或Member checkcolumns中的复选框,Leader checkcolumn中的刻度标记将消失。唯一的问题是,当前如果用户单击“成员”或“查看者”复选列中的“任何”复选框,则“领导者”复选列中的任何选中复选框都将变为未选中状态。但是,我只想取消选中CORRESPONDING复选框(即同一行中的复选框)。以下是checkcolumns的代码,包含checkcolumns和store的网格:
<html>
<head>
<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="ext/js/ux/css/CheckHeader.css" />
<script type="text/javascript" src="ext/js/bootstrap.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.Loader.setConfig({enabled: true, paths:{'Ext.ux': 'ext/js/ux'}});
//Ext.Loader.setPath('Ext.ux', 'ext/js/ux');
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.ux.grid.HeaderToolTip',
'Ext.ux.CheckColumn'
]);
Ext.onReady(function () {
Ext.tip.QuickTipManager.init();
var teststore = Ext.create('Ext.data.ArrayStore', {
fields: [
{name: 'UserID', type: 'asUCString'},
{name: 'Name', type: 'asUCString'},
{name: 'Role', type: 'asUCString'},
{name: 'Leader', type: 'bool'},
{name: 'Member', type: 'bool'},
{name: 'Viewer', type: 'bool'}
],
data: [
['1', 'Hans Hansel', 'Customer/Freelancer', false, false, false],
['2', 'Doreen Duck', 'Consultant', false, false, false],
['3', 'Gerald Goose', 'Client', false, false, false],
['4', 'Frederic Fitzgerald', 'Super User IT', false, false, false],
['5', 'Aimee Anselm', 'Administrator', false, false, false]
]
});
var grid = Ext.create('Ext.grid.Panel', {
id: 'setPermissionsGrid',
title: '',
store: teststore,
plugins: ['headertooltip'],
columns: [
{ text: 'Name', dataIndex: 'Name', width: 120},
{ text: 'Role', dataIndex: 'Role', width: 125},
{ text: 'Leader', dataIndex: 'Leader', xtype: 'checkcolumn', listeners: {'checkchange' : function() {for (var i in teststore.data.items) {teststore.data.items[i].set('Member', false); teststore.data.items[i].set('Viewer', false);}} },width: 68, tooltip: 'Leader'},
{ text: 'Member', dataIndex: 'Member', xtype: 'checkcolumn', listeners: {'checkchange' : function() {for (var i in teststore.data.items) {teststore.data.items[i].set('Leader', false); teststore.data.items[i].set('Viewer', false);}} },width: 68, tooltip: 'Member'},
{ text: 'Viewer', dataIndex: 'Viewer', xtype: 'checkcolumn', listeners: {'checkchange' : function() {for (var i in teststore.data.items) {teststore.data.items[i].set('Leader', false); teststore.data.items[i].set('Member', false);}} },width: 68, tooltip: 'Viewer'}
],
height: 219,
width: 450,
renderTo: Ext.getBody()
});
答案 1 :(得分:1)
我能够使用record.set解决这个问题。我的代码如下:
Ext.Loader.setConfig({enabled: true, paths:{'Ext.ux': 'ext/js/ux'}});
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.ux.grid.HeaderToolTip',
'Ext.ux.CheckColumn'
]);
Ext.onReady(function () {
Ext.tip.QuickTipManager.init();
var teststore = Ext.create('Ext.data.ArrayStore', {
fields: [
{name: 'UserID', type: 'asUCString'},
{name: 'Name', type: 'asUCString'},
{name: 'Role', type: 'asUCString'},
{name: 'Leader', type: 'bool'},
{name: 'Member', type: 'bool'},
{name: 'Viewer', type: 'bool'}
],
data: [
['1', 'Hans Hansel', 'Customer/Freelancer', false, false, false],
['2', 'Doreen Duck', 'Consultant', false, false, false],
['3', 'Gerald Goose', 'Client', false, false, false],
['4', 'Frederic Fitzgerald', 'Super User IT', false, false, false],
['5', 'Aimee Anselm', 'Administrator', false, false, false]
]
});
var grid = Ext.create('Ext.grid.Panel', {
id: 'setPermissionsGrid',
title: '',
store: teststore, //Ext.data.StoreManager.lookup('simpsonsStore'),
plugins: ['headertooltip'],
//selType: 'checkboxmodel',
columns: [
{ text: 'Name', dataIndex: 'Name', width: 120},
{ text: 'Role', dataIndex: 'Role', width: 125},
{ text: 'Leader', dataIndex: 'Leader', xtype: 'checkcolumn', listeners: {'checkchange' : function(column, recordIndex, checked) {var record = teststore.getAt(recordIndex); record.set('Member', false); record.set('Viewer', false); }},width: 68, tooltip: '<b>Team Leader Rights:</b> '},
{ text: 'Member', dataIndex: 'Member', xtype: 'checkcolumn', listeners: {'checkchange' : function(column, recordIndex, checked) {var record = teststore.getAt(recordIndex); record.set('Leader', false); record.set('Viewer', false); }},width: 68, tooltip: '<b>Team Member Rights:</b> '},
{ text: 'Viewer', dataIndex: 'Viewer', xtype: 'checkcolumn', listeners: {'checkchange' : function(column, recordIndex, checked) {var record = teststore.getAt(recordIndex); record.set('Leader', false); record.set('Member', false); }},width: 68, tooltip: '<b>Team Viewer Rights:</b> '}
],
height: 219,
width: 450,
renderTo: Ext.getBody()