Copied to clipboard

Flag this post as spam?

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


  • Dorian Collier 5 posts 25 karma points
    Feb 10, 2012 @ 12:40
    Dorian Collier
    0

    Add "Where" filter to a multi node tree picker property

     

     

     

     

    @Model.Children.Where("catCount = 1")

    It is possible to add a Where filter to a property (catCount) like above. Suppose this catCount is a uComponents multi node tree picker property. How do we add a filter for that?  

     

    Thanks.

     

     

     

     

     

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

    Hi Dorian,

    I think what you have to do is detect what information the property actually contains and then filter. In the case of a multi node tree picker, this will probably be a list of node ID's. So looking for a specific ID can probably be done with something like .Where("catCount.Contains(1)").

    By the way, your example might not work because your filter should be "catCount == 1" I think.

    Cheers,

    Michael.

  • Dorian Collier 5 posts 25 karma points
    Feb 13, 2012 @ 07:33
    Dorian Collier
    0

     

    Hi Michael,

    It gives a node list like below for .ToXml(). ".Contains(1281)" filter doesn't work. It says "No applicable method 'Contains' exists in type 'String'". Also catCount == 1281 or catCount.nodeId doesn't return any value. Seems we need to do some XML processing.

    <MultiNodePicker type="test"><nodeId>1281</nodeId><nodeId>1277</nodeId><nodeId>1278</nodeId><nodeId>1274</nodeId></MultiNodePicker>

     

    Thanks.

     

     

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Feb 13, 2012 @ 10:15
    Michael Latouche
    0

    Hi Dorian,

    Then maybe you can have a look at this link : http://umbraco.com/follow-us/blog-archive/2011/2/28/umbraco-razor-feature-walkthrough-%E2%80%93-part-3

    There is mention that you can parse XML with a dot notation:

    ---- Start quote

    XML Properties

    If you have a field which contains valid XML, and wasn't generated from an RTE, DynamicNode will detect this and allow you to
    access it with . notation
    If there's more than one node with the same name, you'll need to use [] indexing to access the element you want

    Here's an example:
    @Model.xmlProperty.Catalog.Books[1].Genre

    Warning: the property access is case sensitive. Make sure you check your case.
    The root node is removed, so omit that, and remember to check for indexing if you have multiple nodes that might be returned.

    If the XML function is kicking in, your root node may need to be excluded - check umbracoSettings.config for an override of document element types that shouldn't be converted

    --- End quote

    So, you apparently should be able to access your nodeID's as a list with something like this: @Model.catCount.MultiNodePicker.NodeIds

    And you might also want to have a look at this package http://our.umbraco.org/projects/developer-tools/cultiv-razor-examples which gives razor examples about using razor witj all uComponents data types.

    Hope this can help you further.

    Cheers,

    Michael

Please Sign in or register to post replies

Write your reply to:

Draft