当前位置: 代码迷 >> JavaScript >> extjs 四 grid 选中行 只能选择checkbox框
  详细解决方案

extjs 四 grid 选中行 只能选择checkbox框

热度:138   发布时间:2012-11-01 11:11:31.0
extjs 4 grid 选中行 只能选择checkbox框。
Ext.onReady(function() {
var sm = Ext.create('Ext.selection.CheckboxModel',{checkOnly:true});
/*  var selMod = new Ext.grid.CheckboxSelectionModel({ 
        handleMouseDown : Ext.emptyFn, 
                listeners : { 
                    "deselect" : { 
                        fn : function(e, rowIndex, record) { 
                         
                                recordIds.remove(record.data.id); 
                             
                            
                        } 
                    }, 
                    "select" : { 
                        fn : function(e, rowIndex, record) { 
                          
                                recordIds.push(record.data.id); 
                          
                        } 
                    } 
                } 
            });   */
    Ext.create('Ext.data.Store', {
    storeId:'simpsonsStore',
    fields:['name', 'email', 'phone'],
    data:{'items':[
        {"name":"Lisa", "email":"lisa@simpsons.com", "phone":"555-111-1224"},
        {"name":"Bart", "email":"bart@simpsons.com", "phone":"555--222-1234"},
        {"name":"Homer", "email":"home@simpsons.com", "phone":"555-222-1244"},                       
        {"name":"Marge", "email":"marge@simpsons.com", "phone":"555-222-1254"}           
    ]},
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'items'
        }
    }
});
aaa = function (rowIndex){
var name = Ext.getCmp('gridID').getStore().getAt(rowIndex) ;
alert(name.get('name'));
}


Ext.create('Ext.grid.Panel', {
    title: 'Simpsons',
id:'gridID',
    store: Ext.data.StoreManager.lookup('simpsonsStore'),
selModel: sm,
    columns: [
        {header: 'Name',  dataIndex: 'name'},
        {header: 'Email', dataIndex: 'email', flex:1},
        {header: 'Phone', dataIndex: 'phone',renderer:function(value, metaData, record, rowIndex, colIndex, store, view){
return '<a href="javascript:void(0)" onclick="aaa('+rowIndex+')" >'+value+'</a>';
}}
    ],
    height: 200,
    width: 400,
    renderTo: Ext.getBody()
});
});
  相关解决方案