Copied to clipboard

Flag this post as spam?

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


  • Ash 8 posts 28 karma points
    May 10, 2011 @ 13:36
    Ash
    0

    uComponents Multi-node tree picker xPath filter question

    I'm trying to use the xPath filter option in my tree picker. I have tried both disable and enable types, but can't figure out how to filter nodes that have a specific parent in the tree. The start node appears to be set fine:

    //*[name()='Clients']

    The tree looks as follows:

    Clients
    -Client_1
    -ClientVacancies
    -ClientVacancy_1
    -ClientVacancy_2...
    -ClientArchived
    -ClientVacancy_3...
    -Client_2
    -ClientVacancies
    etc...

    I only want to be able to select ClientVacancy nodes that are not archived. I've tried the following xPath filters with enable:

    //*[../'ClientVacancies']
    //*[name()='ClientVacancies']/*
    //*[name()='ClientVacancies']/*[name()='ClientVacancy']
    //*[name()='ClientVacancies']/ClientVacancy
    //ClientVacancies/*[name()='ClientVacancy']
    //ClientVacancies/ClientVacancy

    And none of them enable the ClientVacancy nodes to be selecteable in the tree.

    I'm very new to xPath, so any direction or help would be awesome.

  • Mads Krohn 211 posts 504 karma points c-trib
    Jun 30, 2011 @ 00:12
    Mads Krohn
    0

    I have the exact same issue atm.
    Would love to know a way of filtering nodes based on their parent type.

    Any advice would be greatly appreciated! :) 

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 30, 2011 @ 00:31
    Tom Fulton
    1

    Not tested this, or very confident in it, but it might work:

    //* [local-name() = 'ClientVacancy'][count(./ancestor::ClientArchived) = 0]

    -Tom

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 30, 2011 @ 00:39
    Tom Fulton
    1

    Or parent::ClientArchived might be more efficient if it's always going to be directly under the ClientArchived type

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jun 30, 2011 @ 00:45
    Lee Kelleher
    0

    ... I've had a long day ... so gonna throw this out there quickly - then sleep! :-)

    Try this XPath:

    //ClientVacancy[not(parent::ClientArchived)]

    Cheers, Lee.

  • Mads Krohn 211 posts 504 karma points c-trib
    Jun 30, 2011 @ 01:07
    Mads Krohn
    0

    Thank you both for your replies, it's really appreciated!

    However, after reading the XPath filter notes on MNTP and readig Shannons answer here, it would seem, that is is actually not possible to traverse up or down the xml tree, since the filter is targeting af single node outside the context of the xml tree.

    If this would be in any way possible to implement, I do think it would make a lot of sense to be able to filter nodes in the context of the whole xml tree and not just the single node. For now, back to the drawing board :)

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jun 30, 2011 @ 12:03
    Lee Kelleher
    1

    Ah ok, I didn't realise that MNTP only applied the XPath to individual nodes. So in that case you'd need to have a flag in there (like a yes/no data-type) that would be selected if a node was "archived".

    //ClientVacancy[isArchived != 1]

    Not an ideal solution - but would work for now.

    Cheers, Lee.

  • Mads Krohn 211 posts 504 karma points c-trib
    Jul 04, 2011 @ 11:08
    Mads Krohn
    1

    Just a quick note. I ended up doing like Lee suggested and added a flag to the type of nodes Im trying to target.

    To do this I hooked in to the Document.New and Document.BeforeMove events and applied the flag to the document there.
    In my case I had to able to select a node based on the parent nodes document type alias. So I did like this:

    var parent = new Document(sender.ParentId);
    sender.getProperty("articleTypeAlias").Value = parent.ContentType.Alias;

    The "articleTypeAlias" property is a label data type displayed on the Propertis tab, to hide it as much as possible and to avoid it being edited manually.
    And then on the MNTP settings page I could make a XPath filter like so:

    Article[articleTypeAlias='SomeArticleTypeAlias'] 

    I hope this can help others.

Please Sign in or register to post replies

Write your reply to:

Draft