Copied to clipboard

Flag this post as spam?

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


  • Graham Carr 277 posts 389 karma points
    Jul 21, 2014 @ 12:38
    Graham Carr
    0

    nuPickers and filter by field value

    I am using the nuPickers for dropdown selection of values within my site (e.g. Candidate). I want to be able to choose all nodes with a particular value chosen within the nuPicker but I am not sure of the best way of doing this. Currently I am trying the following:

        var applications = Umbraco.ContentAtXPath("//VacancyApplication[@candidate='1335']");

    However this doesnt work because the candidate field is actually returning nuPickers.PropertyValueConverters.Picker

    Can anyone tell me the best way of selecting all nodes within a tree where the candidate selected by a nuPicker dropdownlist equals a specific ID??

  • Graham Carr 277 posts 389 karma points
    Jul 21, 2014 @ 12:53
    Graham Carr
    0

    The XML produced for the node shows the following:

      <candidate>
        <Picker>
          <Picked Key="1335"><![CDATA[Graham Carr]]></Picked>
        </Picker>
      </candidate>

     

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    Jul 21, 2014 @ 13:18
    Hendy Racher
    0

    Hi Graham,

    Just to check, is your nuPicker DropDown configured to save as Xml ?

    Assuming this picker has a property alias of 'candidate' and is on nodes of type 'VacancyApplication' then the following XPath expression should return all VacancyApplication nodes where a candidate has a value of '1335'

    //VacancyApplication[./candidate//Picked[@Key='1335']]

    HTH,

    Hendy

  • Graham Carr 277 posts 389 karma points
    Jul 21, 2014 @ 13:23
    Graham Carr
    0

    Hi Hendy,

    I am indeed saving as XML and that work's perfectly for me, at least I now know a bit more XPath. Just out of curiosity how would the above be done within a Razor statmenet??

    Thanks once again.

    Graham

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    Jul 21, 2014 @ 13:31
    Hendy Racher
    0

    Sorry, I didn't see your posting of the Xml fragment when replying - hence asking about Xml.

    There are a number of ways to acheive this in Razor, for example Linq with a strongly typed model makes for a nice syntax - but your XPath expression also makes for an efficient query.

  • Graham Carr 277 posts 389 karma points
    Jul 21, 2014 @ 13:34
    Graham Carr
    0

    Thanks, all makes sense! I don't suppose you have a link to a reference for using Linq with strongly typed model, once again this is an area I am still learning!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies