{ xtype: 'grid', sortableColumns: false, reference: 'grid', flex: 1, store: 'panoram.Panoram', columns: [{ xtype: 'rownumberer' },{ text: '主鍵', dataIndex: 'id', name: 'id', id: 'panoramid', width: 100 },{ text: 'viewUuid', dataIndex: 'viewUuid', width: 100 }, { text: '縮略圖路徑', dataIndex: 'thumbPath', width: 100, renderer: function (v) { return '<image style="width : 185px; height : 70px;" src="'+v+'" />' } }, { text: '名稱', dataIndex: 'name', width: 100 }, { text: '風格', dataIndex: 'style', width: 100 }, { text: '戶型', dataIndex: 'houseType', width: 100 }, { text: '空間', dataIndex: 'space', width: 100 },{ text: '創建時間', dataIndex: 'createTime', width:100 },{ text: '操作', xtype: 'actioncolumn', width: 100, items: [{ tooltip: '添加', icon: 'resources/images/icons/new-icon.png', handler: 'bringIntoMyStudio' },{ tooltip: '推薦', icon: 'resources/images/icons/hot-icon.png', handler: 'recommendPanoram' }] }], selModel: { selType: 'checkboxmodel' }, dockedItems: [{ xtype: 'toolbar', items: [ '->', { text: '查詢', iconCls: 'fa fa-search', reference: 'btn_search', handler: 'search' } , { text: '清空條件', iconCls: 'fa fa-search', listeners: { click: 'reset' } }] }, { xtype: 'pagingtoolbar', store: 'panoram.Panoram', dock: 'bottom', displayInfo: true }], listeners: { beforerender: 'gridBeforeRender', render: 'search' } }
這是個items里面的grid,在PanoramController.js里寫好方法
var rec = grid.getStore().getAt(rowIndex);//獲取當前行的對象
rec.get('id')//get()里面加上dataIndex的值,即可獲取該列的值
第一句鎖定行,第二句鎖定列,獲取某一行某一列的數據,也可以用rec把整個grid提交,但是沒什么意義
recommendPanoram: function (grid,rowIndex) { var rec = grid.getStore().getAt(rowIndex); Common.util.Util.doAjax({ url: Common.Config.requestPath('Panoram', 'recommendPanoram'), method: 'post', params: { id:rec.get('id') }, callback: function() { window.store.loadPage(1); } }, function () { Common.util.Util.toast("推薦成功"); }); },