Extjs grid select 选取行内容

 var grid = Ext.create('Ext.grid.Panel', {
            renderTo: Ext.getBody(),
            store: store,
            height: 400,
            width:800,
            selModel: { selType: 'checkboxmodel' },   //选择框
            columns: [                    
                          { text: '型录ID', dataIndex: 'cataId', align: 'left', maxWidth: 80 },
                          { text: '型录编号', dataIndex: 'cataNo',  maxWidth: 120 },
                          { text: '助记标题', dataIndex: 'cataTitle', align: 'left', minWidth: 80 },
                          { text: '应用对象', dataIndex: 'cataObjectName', maxWidth: 80, align: 'left' },                        
                          { text: '发布状态', dataIndex: 'cataPublishName', maxWidth: 80 },
                          { text: '活动截止日期', dataIndex: 'cataEndDate',xtype:'datecolumn',dateFormat :'Y-m-d H:i:s' },
                          { text: '更新时间', dataIndex: 'holyUpdateTime',xtype:'datecolumn',dateFormat :'Y-m-d H:i:s'},
                          { text: '发布时间', dataIndex: 'catapushtime',xtype:'datecolumn',dateFormat :'Y-m-d H:i:s'}
                       ],
            bbar: [{
                xtype: 'pagingtoolbar',
                store: store,
                displayMsg: '显示 {0} - {1} 条,共计 {2} 条',
                emptyMsg: "没有数据",
                beforePageText: "当前页",
                afterPageText: "共{0}页",
                displayInfo: true                 
            }],
             listeners: { 'itemclick': function (view, record, item, index, e) {
               Ext.MessageBox.alert("标题",record.data.cataId);
            }
            },
             tbar:[
             {text:'新增',iconCls:'a_add',handler:showAlert},"-",
             {text:'编辑',iconCls:'a_edit2',handler:showAlert},"-",
             {text:'停用/启用',iconCls:'a_lock'},"-",
             {text:'发布',iconCls:'a_upload',handler:showAlert},"-",
             {text:'组织型录',iconCls:'a_edit',handler:showAlert},"-",
             {text:'管理商品',iconCls:'a_edit',handler:showAlert},"-",
             "->",{ iconCls:"a_search",text:"搜索",handler:showAlert}], 
        });
function showAlert (){
      var selectedData=grid.getSelectionModel().getSelection()[0].data;

      Ext.MessageBox.alert("标题",selectedData.cataId);
 }
}); 


这个只能获取单行数据
function showAlert (){ var selectedData=grid.getSelectionModel().getSelection()[0].data; Ext.MessageBox.alert("标题",selectedData.cataId); }
这个可以获取选择的多行数据
 var rows = grid.getView().getSelectionModel().getSelection();
                var msg = "";
                for (var i = 0; i < rows.length; i++) {
                    msg = msg + rows[i].get('cataId') + ',';
                }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章