ExtJS 4 MVC 和视图:如何过滤(或创建)“子视图”哪个在视图中?
您经常需要查看视图中的视图。
例如,一个拥有许多电话号码的客户。 因此,您为客户创建一个视图:
- app/view/client/Edit.js
并为电话号码创建两个视图:
- app/view/phone/Edit.js
- app/view/phone/List.js
正确“绑定”它们的方法是什么? (我的意思是在客户端编辑视图中,显示该客户的电话(并且仅显示该客户的电话))。
我已经完成了这些示例,并且根据这些“经验教训”(远不能用于制作专业的东西)制作了自定义 MVC:
- http://docs.sencha.com/ext-js/4-0/#/guide/application_architecture
- <一个href="http://www.sencha.com/learn/the-mvc-application-architecture/" rel="nofollow noreferrer">http://www.sencha.com/learn/the-mvc-application-architecture /
- http://www.sencha.com/learn/architecting-your-app-in-ext-js-4-part-1
- http://www.sencha.com/learn/architecting-your-app-in-ext-js-4-part-2
您可以在我的网站上测试我的示例:
http://doonoo.com/intranet/gs.php
这是一个完整的 CRUD 系统(没有 CRUD 示例可以被发现与MVC 教程(这对我来说“有点”重要))。
但现在我想做另一个关于“电话”的(模型+商店+视图),但是当我们编辑用户时,我想显示他/她自己的电话号码,并且(也许)添加/删除他们的电话号码。这是一种“打开用户视图,其中包含使用用户 ID 过滤的电话视图”。
有什么想法/建议吗? 到目前为止,我所做的是将“电话”视图创建到“编辑用户视图”中,但我不知道如何应用过滤器。我被困住了。
任何想法欢迎!
它的工作原理如下:
You often need View in View.
For example, a client that has many phone numbers.
So you create a view for the client:
- app/view/client/Edit.js
and you create two views for the phone numbers:
- app/view/phone/Edit.js
- app/view/phone/List.js
What is the way to "tie" them properly? (I mean in the client Edit view, show Phones of this client (and only of this one)).
I've already gone through those examples, and I've made my custom MVC based on those "lessons" (that are far from being usable for making professionnal stuff):
- http://docs.sencha.com/ext-js/4-0/#/guide/application_architecture
- http://www.sencha.com/learn/the-mvc-application-architecture/
- http://www.sencha.com/learn/architecting-your-app-in-ext-js-4-part-1
- http://www.sencha.com/learn/architecting-your-app-in-ext-js-4-part-2
You can test my example at my website here:
http://doonoo.com/intranet/gs.php
This is a full CRUD system (no CRUD example could be found with the MVC tutorials (and this is "kind of" important to me)).
But now I'd like to make another (model + store + view) about "phone", but when we edit the user, I want to display his/her own phone numbers, and (maybe) add / delete their phone numbers. This is kind of "opening a user view, which contains a phone view that is filtered with the user id".
Any idea / suggestion?
What I've come so far is to create the "phones" view into the "edit user view" but I don't know how to apply the filter. I'm stuck.
Any idea welcome!!
Here's how it should work:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题不是很清楚,但让我尝试一下 -
您的编辑用户视图只不过是一种表单。
当呈现给用户时,该表单具有与电话号码相关的字段。 (家庭、移动、工作等)
如果您希望能够从编辑用户表单以外的地方编辑电话号码,那么您是对的,您需要一个“单独”视图以便可以重用。在这种情况下,您可以扩展字段集(app/view/phone/Edit.js 扩展字段集)并将其添加到编辑用户表单。该字段集本身无法使用(它没有任何保存逻辑),但可以跨表单重用。当您的编辑用户表单提交时,它也会自动提交电话字段。
Your question is not very clear but let me take a stab -
Your edit user view is nothing but a form.
This form, when presented to the user, has phone number related fields. (home, mobile, work, etc)
If you want to be able to edit phone numbers from places other than edit user form, you are right, you need a "separate" view so that it can be reused. In this case, you can extend a fieldset (app/view/phone/Edit.js extends fieldset) and just add it to edit user form. This fieldset by itself wont be usable (it wont have any save logic) but it will be reusable across forms. When your edit user form is submitting, it will automatically submit phone fields too.