用法与CheckboxSelectionModel相同
Ext.ns('Ext.ux.grid');
Ext.ux.grid.RadioSelectionModel = function(config) {
Ext.ux.grid.RadioSelectionModel.superclass.constructor.call(this, config);
this.renderer = function(v, p, record){
var checked = record === this.selections.get(0);
var retval = '<div class="x-grid3-row-radio"><input type="radio" name="' + this.id + '"'+ (checked ? 'checked="checked"' : '')+ '></div>';
return retval;
}.createDelegate(this);
};
Ext.extend(Ext.ux.grid.RadioSelectionModel, Ext.grid.RowSelectionModel, {
header: '<div> </div>',
width: 20,
sortable: false,
fixed: true,
dataIndex: '',
id: 'radio',
singleSelect: true,
selectRow: function(index) {
Ext.ux.grid.RadioSelectionModel.superclass.selectRow.apply(this, arguments);
var row = Ext.fly(this.grid.view.getRow(index));
if(row) {
row.child('input[type=radio]').dom.checked = true;
}
}
});