Extjs6获取Grid里的数据(数据源)

{
        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("推荐成功");
        });
    },

 

posted @ 2017-07-27 19:42  Rest探路者  阅读(3694)  评论(0编辑  收藏  举报
levels of contents