我有一個fieldset包含一個有3個checkcolumns的網格:Leader,Member和Viewer。如果用戶點擊領導者檢查列中的複選框,則應禁用成員和查看者檢查列中的相應複選框(即,用戶不應該能夠點擊這些複選框)。如果用戶點擊成員或查看器checkcolumns中的複選框,也是如此;其他複選框不應該是可點擊的。任何想法如何去做這件事?checkcolumn ext js
0
A
回答
1
RadioGroup不可行,因爲應用程序需要允許用戶檢查多個複選框(在checkcolumn中)。我已經部分解決了這個問題:現在,如果我點擊領導者checkcolumn中的任何複選框,然後單擊Viewer或Member checkcolumns中的複選框,領導者checkcolumn中的勾號消失。唯一的問題是,如果用戶點擊成員或查看器檢查列中的ANY複選框,那麼領導者檢查列中的任何選中的複選框將被取消選中。但是,我只想要取消選中相應複選框(即同一行中的那個複選框)。這裏是checkcolumns的代碼,包含checkcolumns和商店的網格:
<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
我能用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()
相關問題
- 1. 提交電網的Ext JS
- 2. 從Ext JS 2遷移到Ext JS 4
- 3. 從EXT js 3.4移植到EXT js 5.0
- 4. Ext JS 6從Ext JS 4.1.3遷移到
- 5. 如何防止在ext treepanel中更改checkcolumn
- 6. Window.open()in ext Js
- 7. Ext JS的beforeedit
- 8. Ext JS UX - RowPanelExpander
- 9. Ext JS - A start
- 10. Ext js許可
- 11. Ext js grid seethrough
- 12. Ext Js和zeroclipboard
- 13. 插入Ext-js
- 14. 缺點ext js
- 15. HTML ext js fieldsets
- 16. Ext JS Cascading Combobox
- 17. Extjs checkColumn
- 18. checkcolumn validation
- 19. Ext JS 4 MVC Combobox
- 20. 如何在ext js
- 21. Ext JS Dependent combo box
- 22. Ext JS 4.2引擎
- 23. Multi Series Ext Chart JS
- 24. Ext Js網格列
- 25. Ext JS with C#Backend
- 26. Ext JS加載店
- 27. ext js手風琴
- 28. Ext JS等價物
- 29. Ext JS - Store vs. JsonStore
- 30. EXT JS佈局XHTML
您是否嘗試過使用RadioGroup? http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.RadioGroup – Patton