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("推荐成功"); }); },
作者:Rest探路者
出处:http://www.cnblogs.com/Java-Starter/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意请保留此段声明,请在文章页面明显位置给出原文连接
Github:https://github.com/cjy513203427
分类:
ExtJs
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?