EXTJS:如何确定是否已单击数据网格中的标题复选框



我想知道是否单击了标题复选框(全选(。我从煎茶小提琴那里得到了这个例子:

https://fiddle.sencha.com/#fiddle/1gvv&view/editor

'Ext.application({ 名称:"小提琴", 启动: 函数(( {

// Define our data model
Ext.define('MyModel', {
extend: 'Ext.data.Model',
fields: ['firstField', 'secondField']
});
// Generate mock data
var data = [{
"firstField": "one",
"secondField": "1"
}, {
"firstField": "two",
"secondField": "2"
}, {
"firstField": "three",
"secondField": "3"
}, {
"firstField": "four",
"secondField": "4"
}, {
"firstField": "five",
"secondField": "5"
}];
// create the Data Store
var store = Ext.create('Ext.data.Store', {
// destroy the store if the grid is destroyed
autoDestroy: true,
model: 'MyModel',
proxy: {
type: 'memory'
},
data: data
});
var sm = new Ext.selection.CheckboxModel({
checkOnly: true,
listeners: {
selectionchange: 'onSelectionChange'
}
});
var grid = Ext.create('Ext.grid.Panel', {
store: store,
selModel: sm,
columns: [{
header: 'firstField',
dataIndex: 'firstField',
flex: 1
}, {
header: 'secondField',
dataIndex: 'secondField',
flex: 1
}],
tbar: [{
xtype: 'textfield',
fieldLabel: 'firstField',
itemId: 'mytextfield'
}, {
text: 'Select',
handler: function() {
// try to find the record having the firstField field as the entered one
var selectedRecord = grid.getStore().findRecord('firstField', grid.down('#mytextfield').getValue()); 
if (selectedRecord) {
grid.getSelectionModel().select(selectedRecord);
}
}
}]
});
new Ext.window.Window({
width: 700,
height: 400,
items: grid,
layout: 'fit',
closable: false
}).show();

}

}(;'

我已经放置了onSelectionChange侦听器,但是如果选择了"全部",该放入里面才能知道什么?

感谢您帮助大家。

我今天在寻找完全相同的东西时遇到了你的问题。

经过一些尝试,这就是我得到的——

煎茶小提琴

本质上,您需要获取checkcolumn,然后查看针对它的allChecked属性是否设置为true

最新更新