Hi I am writing an backend extension that lists all members. I have already done that, however I would like the list to be sorted by name of the member. I have tried using tree.treeCollection.Sort() with the code below, but by doing that no members is shown in the tree. How do I sort the members in the code below?
public override void Render(ref XmlTree tree)
{
var members = Member.GetAll;
foreach (Member m in members)
{
XmlTreeNode xNode = XmlTreeNode.Create(this);
xNode.Text = m.getProperty("Navn").Value.ToString();
xNode.Action = "javascript:openMember('" + m.Id +"')";
xNode.Icon = "member.gif";
xNode.OpenIcon = "member.gif";
tree.Add(xNode);
}
}
Is a call to an extension method (http://msdn.microsoft.com/en-us/library/bb534966.aspx) which takes a delegate which returns the key to sort on. x => x.Text is a lambda function, where x is an instance of Member, defined by generics.
Sorting of members in Custom tree
Hi I am writing an backend extension that lists all members. I have already done that, however I would like the list to be sorted by name of the member. I have tried using tree.treeCollection.Sort() with the code below, but by doing that no members is shown in the tree. How do I sort the members in the code below?
Regard Tarrild
If you're using .NET 3.5 you can just run LINQ over the top of it:
I have never used LINQ before. Could you provide me with a short example?
Err, that was the example.
The statement:
Is a call to an extension method (http://msdn.microsoft.com/en-us/library/bb534966.aspx) which takes a delegate which returns the key to sort on. x => x.Text is a lambda function, where x is an instance of Member, defined by generics.
Sorry, I was not observant enough to see the differences in the code.
Thank you very much for your reply, it worked like a charm.
is working on a reply...