Copied to clipboard

Flag this post as spam?

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


  • Lex Godthelp 15 posts 99 karma points
    Aug 02, 2017 @ 12:55
    Lex Godthelp
    0

    Last item from Multinode Tree Picker

    Hello guys,

    I'm currently working on a project in 7.6.1 and i ran into an issue with the Multinode Tree picker. When I select two or more nodes, I want the last selected item to behave differently from the rest. I set up a code which seems to not work quite as expected:

    @if(CurrentPage.HasValue("experts")){
    var expertList = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("experts");
    @foreach(var expert in expertList){
        <div>do some of this and that</div>
        if(!expert.IsLast()){
            <div>do something special</div>
        }
    }}
    

    Works not entirely as i figured, since it counts unselected nodes in the parentfolder aswell, thus IsLast is not working. Any suggestions?

    • Lex
  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 02, 2017 @ 12:58
    Alex Skrypnyk
    100

    Hi Lex

    Try this code:

    @if (CurrentPage.HasValue("experts"))
    {
        var expertList = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("experts");
    
        var last = expertList.Last();
    
        foreach (var expert in expertList)
        {
            <div>do some of this and that</div>
            if (!expert.Equals(last))
            {
                <div>do something special</div>
            }
        }
    }
    

    Thanks,

    Alex

  • Lex Godthelp 15 posts 99 karma points
    Aug 02, 2017 @ 13:01
    Lex Godthelp
    1

    Thanks Alex, that did the trick!

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Aug 02, 2017 @ 13:02
    Alex Skrypnyk
    0

    You are welcome, have a nice day!

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft