ExtJS 4:将网格转换为 JSON 以存储在数据库中或转换为 PHP 对象
我想采用现有的 ExtJS 4 网格并将其转换为 JSON 对象,以便传输到我的应用程序 (PHP) 的后端。我需要做什么才能实现这一点?我是否只需要覆盖网格的 getState
方法和列对象的 getColumnState
方法?
最好的方法是什么?
I want to take an existing ExtJS 4 Grid and convert it into a JSON object for transport to the backend of my application (PHP). What do I need to do to make this happen? Do I simply need to overwrite the getState
method of the grid and the getColumnState
method of the column object?
What's the best approach for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
覆盖列的
getColumnState
是个好主意。默认情况下,它假设您将再次使用具有相同视图的数据,并且列 ID 之类的内容将是相同的。我现在有getColumnState
返回一个可用作列配置的对象。从网格中添加您需要的任何其他内容,并在您发现有用时存储。我发现我需要
text
、dataIndex
、hidden
、draggable
、hideable
、可调整大小
、minWidth
和flex
。 (有时还有宽度)。编辑:
您想要类似的东西:
如果您需要这些东西,请查看原始的 getColumnState 以了解它们对分组列和宽度与 Flex 的作用。
然后只需调用 grid.headerCt.getColumnsState() 即可
Overriding the
getColumnState
for the column is a good idea. By default it assumes you'll be using the data with the same view again and that things like the column ids will be the same. I now havegetColumnState
returning an object that can be used as a config for a column. Add on whatever else you need from the grid and store as you find it useful.I've found I need
text
,dataIndex
,hidden
,draggable
,hideable
,resizable
,minWidth
andflex
. (And sometimes width).Edit:
You want something like:
Look at the original getColumnState to see what they do about grouped columns and width vs flex if you need those things.
Then just call
grid.headerCt.getColumnsState()