Extjs动态Grid,JsonStore动态绑定fields问题

伟大的左前卫 2013-09-20 05:59:15
项目需求要用ext实现完全动态的Grid,即表头、数据都是可变的,不同业务实体数据可在同一模板页面上实现增删改查功能。参考了网上很多资料,似乎都是先请求得到json格式的fields和data,然后去newGrid及window,这种方式的问题是想刷新数据的话,必须刷新整个页面,也就是重建GridPanel和Window。而我希望的效果是,点击刷新按钮时,只是重新载入数据,就像固定field情况下调用store.load()的效果。测试了好久,发现JsonStore的fields属性似乎必须先定义好,有没有办法在JsonStore中请求后台得到动态的fields数组?
...全文
387 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
伟大的左前卫 2013-12-13
  • 打赏
  • 举报
回复
引用 4 楼 Joden1234 的回复:
LZ你是怎么实现的,分享下
用ext同步http请求实现了,就是先取得fields的json,然后new出JsonStore来。其实这也是问题的核心核心所在。
xuhuaiguang123 2013-11-15
  • 打赏
  • 举报
回复
Joden1234 2013-10-30
  • 打赏
  • 举报
回复
LZ你是怎么实现的,分享下
lzpggg 2013-09-20
  • 打赏
  • 举报
回复
如果你不想改变store也可以传入原来的store,只改变列模型,但是要注意的是与列模型和store相关的操作和设置可能要重新绑定,比如autoExpandColumn 、分页toolbar以及与此相关的插件等。
fzfei2 2013-09-20
  • 打赏
  • 举报
回复
那就整个表新建
lzpggg 2013-09-20
  • 打赏
  • 举报
回复
reconfigure( Ext.data.Store store, Ext.grid.ColumnModel colModel ) : void Reconfigures the grid to use a different Store and Column Model and fires the 'reconfigure' event. The View will be bound to the new objects and refreshed. Be aware that upon reconfiguring a GridPanel, certain existing settings may become invalidated. For example the configured autoExpandColumn may no longer exist in the new ColumnModel. Also, an existing PagingToolbar will still be bound to the old Store, and will need rebinding. Any plugins might also need reconfiguring with the new data. Parameters: store : Ext.data.Store The new Ext.data.Store object colModel : Ext.grid.ColumnModel The new Ext.grid.ColumnModel object Returns: void

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧