ExtJS树多个模型(嵌套)

发布于 2024-12-11 10:10:39 字数 297 浏览 0 评论 0原文

我有一棵异步加载的树。我有两个模型,经理和用户。

管理员可以是父节点,也可以是叶子节点,但用户只能是叶子节点。因此,一个 Manager 可以有任意数量的上级或下级 Manager,但 I User 只能是 Manager 的子级。

我已经为 User 和 Manager 模型设置了代理,并将 Manager 设置为 TreeStore 的模型参数。我尝试使用hasMany和belongsTo来描述关系,希望每次展开节点时,都会发送针对用户和管理者的获取。它不起作用。我只得到经理,而不是用户。

有人对处理此类关系有什么建议吗?

I have a tree that is loading asynchronously. I have two models, Manager and User.

Managers can be parent nodes or leaf nodes, but Users can only be leaf nodes. So, a Manager can have any number of Managers above or below him, but I User can only be the child of a Manager.

I have set up proxies for the User and Manager models and set Manager as the TreeStore's Model parameter. I tried using hasMany and belongsTo to describe the relations, hoping that every time I expand a node, a get for Users and for Managers is sent. It isn't working. I'm only getting Managers, not Users.

Anyone have any tips for working with these kinds of relationships?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼忆七猫命九 2024-12-18 10:10:39

创建新模型“Employee”,该模型将具有属性 (IsUser) 并加载到经理和用户 IE 列表中:

   Ext.regModel('Employee', {
        fields: [
            { name: 'ID', type: 'int' },
            { name: 'Name', type: 'string' },
            { name: 'LastName', type: 'string' },
            //....
            { name: 'IsUser', type: 'int' }
        ]
    });

用于填充的 SQL 查询应如下所示:

SELECT id, name, lastname, 0 as IsUser

FROM managers ...

UNION

SELECT id, name, lastname, 1 as IsUser

FROM users ...

Create new model 'Employee' that will have a property (IsUser) and load into list both managers and users IE:

   Ext.regModel('Employee', {
        fields: [
            { name: 'ID', type: 'int' },
            { name: 'Name', type: 'string' },
            { name: 'LastName', type: 'string' },
            //....
            { name: 'IsUser', type: 'int' }
        ]
    });

And SQL query for populating should look like this:

SELECT id, name, lastname, 0 as IsUser

FROM managers ...

UNION

SELECT id, name, lastname, 1 as IsUser

FROM users ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文