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 @   Rest探路者  阅读(3702)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
levels of contents
点击右上角即可分享
微信分享提示