Get number of users in each role (User Administration)

Posted by Community Admin on 04-Aug-2018 17:34

Get number of users in each role (User Administration)

All Replies

Posted by Community Admin on 14-Aug-2012 00:00

We're trying to get in Sitefinity 5.1 the same features available in Sitefinity 3.7. In this case, when managing users and viewing the list of roles in the right column, we'd like to display the number of users in each role group.
As mentioned this was offered by default in Sitefinity 3.7.
We've tried using the template available in the SDK:
WidgetTemplates.zip -- Backend -- Security -- Principlas -- UsersCommandPanel.ascx.
We uncommented the following commented strings:

<div class="sfAllFilter sfRolesFilter">
        <asp:LinkButton runat="server" ID="cmdLoggedInUsers" CommandName="LoggedInUsers" Text="<%$ Resources:Labels, FilterLoggedInUsersText %>"
           OnClientClick="LoggedInUsers(this);return false;" ></asp:LinkButton>
           <%--<span class="sfCount" ID="LoggedInCount">(0)</span>--%>
    </div>

And
<sitefinity:GenericCollectionBinder ID="rolesBinder" runat="server"
        TargetId="rolesList"
        ServiceUrl="~/Sitefinity/Services/Security/Roles.svc"
        BindOnLoad="true"
        OnClientItemEditCommand="rolesBinder_EditItemCommand"
        OnClientDataBound="rolesBinder_DataBound"
        OnClientItemDataBound="rolesBinder_ItemDataBound"
        DataKeyNames="Name"
        DataMembers="Name, UsersInRole, ProviderName, Id, ProviderTitle"
        <Containers>
            <sitefinity:BinderContainer runat="server" RenderContainer="false" TemplateHolderTag="UL"
                <li>
                    <a id="roleCommand" sys:href="javascript:void(0);" class="editCommand">NameProviderTitle</a> <%--<span class="sfCount">(Number(UsersInRole))</span>--%>
                </li>
            </sitefinity:BinderContainer>
        </Containers>     
    </sitefinity:GenericCollectionBinder>

However, the expression Number(UsersInRole)
produces 0 (zero).

Is UsersInRole DataMember not included yet in the collection?

Any help would be most welcome.
P.S. I should mention that the edited template has been registered in Administration -- Settings -- Advanced -- Controls -- ViewMaps





This thread is closed