{ xtype: 'grid', sortableColumns: false, reference: 'grid', flex: 1, store: 'panoram.Panoram', columns: [{ xtype: 'rownumberer' },{ text: '主键', dataIndex: 'id', name: 'id', id: 'panoramid', 100 },{ text: 'viewUuid', dataIndex: 'viewUuid', 100 }, { text: '缩略图路径', dataIndex: 'thumbPath', 100, renderer: function (v) { return '<image style="width : 185px; height : 70px;" src="'+v+'" />' } }, { text: '名称', dataIndex: 'name', 100 }, { text: '风格', dataIndex: 'style', 100 }, { text: '户型', dataIndex: 'houseType', 100 }, { text: '空间', dataIndex: 'space', 100 },{ text: '创建时间', dataIndex: 'createTime', 100 },{ text: '操作', xtype: 'actioncolumn', 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("推荐成功"); }); },