想像大家请教一下:
我在表格中定义了复选框var userSm = new Ext.grid.CheckboxSelectionModel();
如何定义一个触发函数使得在复选框的状态改变时能够触发该函数?
主要是想实现一个分页的功能,那如何定义一个在翻页的时候能够触发的函数呢?
麻烦大家帮忙了,谢谢~~ :D
[b]问题补充:[/b]
问一下selectionchange是指设置的userSm = new Ext.grid.CheckboxSelectionModel(); 这个复选框当选中/未选中状态改变的时候出发的吗?呵呵~~
看下源码,或者加这样一段话,跑以下你就知道了.
console.log是firebug的输出,如果你不在ff里面,就换成其他的alert吧
[code="javascript"]
new Ext.grid.CheckboxSelectionModel({
listeners:{
'rowselect':function(sm,rowIndex,record){
console.log('rowselect',rowIndex)
},
'rowdeselect':function(sm,rowIndex,record){
console.log('rowdeselect',rowIndex)
},
'selectionchange':function(sm){
console.log('selectionchange',sm.getSelections().length);
}
}
[/code]
beforerowselect : ( SelectionModel this, Number rowIndex, Boolean keepExisting, Record record )
Fires before a row is selected, return false to cancel the selection.
RowSelectionModel
rowdeselect : ( SelectionModel this, Number rowIndex, Record record )
Fires when a row is deselected. To prevent deselection lock the selections.
RowSelectionModel
rowselect : ( SelectionModel this, Number rowIndex, Ext.data.Record r )
Fires when a row is selected.
RowSelectionModel
selectionchange : ( SelectionModel this )
Fires when the selection changes
RowSelectionModel
监听rowdeselect事件
selectionchange : ( SelectionModel this )
Fires when the selection changes
Listeners will be called with the following arguments:
* this : SelectionModel
是的,他就是对这个选择模型的事件
是这样的,
如果你初始化后,
1.选择某行,则触发rowselect->selectionchange 事件
2.如果你再选择另一行
2.1如果你是点击行的,那前一个选择行会被取消掉,
这时候会触发:rowdeslect -> selectionchange -> rowselect -> selectionchange
2.2如果你点击的是checkbox,那就会选中2个.
这时候会触发rowselect -> selectionchange