用户组管理 [英] User groups management

查看:120
本文介绍了用户组管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为网站实施用户管理功能. 我正在使用ASP.NET MVC 3,实体框架4.1,MvcScaffolding.

I am trying to implement user management functionality for a web site. I am using ASP.NET MVC 3, Entity Framework 4.1, MvcScaffolding.

让我们考虑一下这些实体:

Let's consider the entities:

用户实体:

public class User
{
    public int Id
    {
        get;
        set;
    }

    public string FirstName
    {
        get;
        set;
    }

    public string LastName
    {
        get;
        set;
    }

    public virtual ICollection<UserGroup> Groups
    {
        get;
        set;
    }
}

用户组实体:

public class UserGroup
{
    public int Id
    {
        get;
        set;
    }

    public string Name
    {
        get;
        set;
    }

    public virtual ICollection<User> Users
    {
        get;
        set;
    }
}

如您所见,用户与用户组实体之间存在多对多关系.

As you see, there is the many-to-many relationship between the user and the user group entities.

因此,我想使用以下UI来编辑用户组:

So, I would like to have the following UI for editing an user group:

有两个网格: 1. 用户网格包含正在编辑的用户组的当前状态. 2. 浏览用户网格包含所有用户(已属于该用户组的用户除外).单击此网格的用户行时,该用户将被移至用户网格.另外,此网格应支持分页,过滤和排序,以提供良好的用户浏览.

There are two grids: 1. Users grid contains current state of the user group which is being edited. 2. Browse users grid contains all users (except the users which already belong to the user group). When the user row of this grid is clicked, the user will be moved to the users grid. Also, this grid should support paging, filtering and sorting to provide nice user browsing.

因此,用户为用户组选择用户,然后单击保存"按钮.用户组控制器类应保存更改.

So, the user picks users for the user group and then clicks the "Save" button. User group controller class should save the changes.

现在的问题是:如何实现功能?对于这种多对多关系问题,有什么很好的例子吗? 如果没有简单的解决方案,您可以建议我使用哪个用户组管理UI?

Now the question: how can the functionality be implemented? Is there any good example for the such many-to-many relationship problem? If there is no simple solution, what UI for the user group management could you advise me to use?

P.S.我对ASP.NET还是个新手,所以我不知道如何实现这种动态网格.

P.S. I am quite novice with ASP.NET, so I don't realize how to implement such dynamic grids.

更新1: 我已经看过jqGrid的例子. 链接 参见高级->多选 有问题,更换过滤器时,复选框的选择将重置.如何在过滤器更改的情况下存储所有选定的ID?

Update 1: I have looked through the jqGrid examples. link See Advanced -> Multi Select There is the problem, the checkboxes' selection is reset when you change the filter. How to store all selected IDs despite the filter change?

推荐答案

Telerik具有出色的网格: http://demos.telerik.com/aspnet-mvc/grid/detailsajax .
我无法理解您的整个情况,尤其是这样:浏览用户网格包含所有用户(已属于该用户组的用户除外).单击此网格的用户行时,该用户将被移至用户网格. .
我认为情况可能是这样的:
如果用户在具体组中,则会显示两个网格:
a)组中现有的用户,其中每一行包含用户信息和按钮删除
b)组中不存在的用户,其中每行包含用户信息和按钮添加

Telerik has great grid: http://demos.telerik.com/aspnet-mvc/grid/detailsajax.
I could not understand your whole scenario, especially this: "Browse users grid contains all users (except the users which already belong to the user group). When the user row of this grid is clicked, the user will be moved to the users grid".
I think scenario could be this:
If user is at concrete group, two grids are shown:
a) users existing in group, where each row contains user info and button remove
b) users not existing in group, where each row contains user info and button add

在这种情况下,所有逻辑都非常简单,您不需要任何奇特的逻辑,因为所有内容都在同一页面上.

In such case, all logic is quite straightforward, you don't need any fancy logic, as everything is on same page.

在用户页面中,可能会有一个带有组的网格,并且如果用户在该组中,则该行中的按钮将被删除,如果用户不在,则该行将具有按钮的添加.精心选择的用户dto可以进行编辑视图,这也将非常容易实现.

In user page, there could be a grid with groups, and if user is in that group, in that row is button remove, and if user is not, there is button add. With well chosen user dto for edit view, that will be also quite straigtforward to implement.

这篇关于用户组管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆