Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sander van de Pas 74 posts 147 karma points
    Jun 01, 2012 @ 12:43
    Sander van de Pas
    0

    Get Members where the property (MNTP) contains the id of the page

    I added custom properties for the members. One is a Multi-Node -Tree-Picker (memberPages). On a specific page I want to show the members who selected that page on the MNTP.

    So here is my code, which works, but I think it can made easier/faster...

    @foreach (dynamic m in members)
    {
    dynamic pages= new DynamicXml(m.getProperty("memberPages").Value);
    var showItem = false;

            foreach (dynamic d in  pages )
            {
                    dynamic node = new DynamicNode(d.InnerText);

                    if (node.Id == Model.Id)
                    {
                        showItem = true;
                    }
            }

            if (showItem) {                
                   //do something
            }
    }

    Hope someone can help me??

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 01, 2012 @ 13:18
    Michael Latouche
    0

    Hi Sanders,

    What exactly does the m.getProperty("memberPages").Value give back? Is this actual XML, or a comma-separated list?

    Cheers,

    Michael.

  • Sander van de Pas 74 posts 147 karma points
    Jun 01, 2012 @ 13:39
    Sander van de Pas
    0

    Hi Michael,

    It returns XML like this:

    <MultiNodePicker>
      <nodeId>1548</nodeId>
      <nodeId>1550</nodeId>
    </MultiNodePicker>

    Thanx!

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 01, 2012 @ 14:01
    Michael Latouche
    0

    Hi Sander,

    Then I don't see much possibility for improvement. Maybe you can make use of the Where method in Razor to make your code shorter (not tested):

    @foreach (dynamic m in members)
    {
            dynamic pages= new DynamicXml(m.MemberPages);
            var showItem = pages.Where("new DynamicNode(InnerText).Id == Model.Id").Count() > 0;
            if (showItem) {                
                   //do something
            }
    }

    Hope this works/help :-)

    Cheers,

    Michael.

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jun 01, 2012 @ 14:10
    Hendy Racher
    0

    Hi Sander,

    If I understand correctly, instead of checking every member to see if they selected the current page, how about wiring up Relations to that MNTP via the MultiPicker Relations (with a reverse index), and then you can do one quick hit to get all members associated to a given page ?

    HTH,

    Hendy

  • Sander van de Pas 74 posts 147 karma points
    Jun 05, 2012 @ 13:32
    Sander van de Pas
    0

    Thanks both!

    @Michael: This doesn't work...I leave it so for now...

    @Hendy: Maybe I use your option in a later stadium!

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 05, 2012 @ 13:37
    Michael Latouche
    0

    Ok too bad...

    Good luck further :-)

    Cheers,

    Michael.

Please Sign in or register to post replies

Write your reply to:

Draft