Developer forum

Forum » CMS - Standard features » User group sort using razor

User group sort using razor

Peter Kristensen
Reply

Hi.

I have a group of users sorted in a particular way and want to display the users as sorted using razor.
It is no problem to display the users as in DB or by name using Linq:

       @foreach (LoopItem i in GetLoop("Item.Brugere").OrderBy(o=>o.GetString("UserManagement:User.Name")).ToList())

By how do I display the users as I intended in my user group sort?

Can’t seem to find anything in the forum, documentation or example code. Can I get a hint here?


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Peter,
in the User object there is a property "UserSortCollection" which contains a List of "UserSort" objects which has the GroupID and Sort properties.
I am not very much familiar with templates output but the idea could be to make an instance of a "user" object and query its UserSortCollection on specific "GroupId" value and gets the Sort
from there.
Regards, Dmitrij

Votes for this answer: 1
 
Peter Kristensen
Reply

Hi Dmitriy.

You realeased my brain lock. Thank you for that. :-)

BR.

Peter

 
Peter Kristensen
Reply

Hi again.

After trying to get Dmitriy's good idea to work, I must admit that I was unable to get the idea to work in my razor code.
Could it be that there is a wise coder out there that can bring me closer to a solution?

Thanks in advance.

 

 
Peter Kristensen
Reply

Is there anyone who can help? I am completely out of ideas.

 

You must be logged in to post in the forum