Copied to clipboard

Flag this post as spam?

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


  • Jenni Marsh 26 posts 46 karma points
    Jan 30, 2012 @ 17:41
    Jenni Marsh
    0

    Confused by results from Node.ChildrenAsTable()

    Hi,

    I am relatively new to Umbraco and come from an ASP.NET programming background, therefore I am trying to use the API.

    My website has 6 pages, producing the following document type structure:

    ---- Homepage
    --------News List
    --------TextPage
    --------TextPage
    --------TextPage
    --------News List

    If I set my Node variable to be equal to the Homepage, via the following hardcoded ID and then call ChildrenAsTable:

    Dim RootNode As New Node(1050)
    RootNode.GetChildrenAsTable()

     

    this seems to return a datatable with only two rows, i.e. the two pages of type "News List". I would expect it to have 5 rows, one for each child?

    If I view RootNode.ChildrenAsList() then there are clearly 5 children, so I'm quite confused. Is this a known bug, or I am doing something wrong?

    Thanks,
    Jenni

     

     

     

     

     

     

  • Jenni Marsh 26 posts 46 karma points
    Jan 30, 2012 @ 18:18
    Jenni Marsh
    0

    Sorry, I forgot to mention my Umbraco version. I'm using 4.6.

  • Rodion Novoselov 694 posts 859 karma points
    Jan 31, 2012 @ 00:24
    Rodion Novoselov
    1

    Hi. It's not a bug. "GetChildrenAsTable" fills the datatable with the children of the same content type as the first child of the node has.

  • Jenni Marsh 26 posts 46 karma points
    Jan 31, 2012 @ 10:19
    Jenni Marsh
    0

    Really? Wow, I never would''ve guessed that. Thanks for the reply Rodion.

    I don't seem to be able to find anywhere either on the internet or in the library on my machine that tells me this sort of information. None of the methods have descriptions.

    [Added by edit]: On second thoughts, if this is the case, what is the use of the optional parameter that lets you specify the alias of the document type you wish to retrieve? In my experience it only returns documents if you use the alias of the first document type, i.e. in my example it returns results if you use "News List" as the parameter, but not if you use "Text Page".

  • Rodion Novoselov 694 posts 859 karma points
    Jan 31, 2012 @ 11:08
    Rodion Novoselov
    0

    The parameterised overload should return all nodes of the type with a type alias passed. At least it's supposed to - I've actually never used this DataTable representation of content.

  • Jenni Marsh 26 posts 46 karma points
    Jan 31, 2012 @ 11:55
    Jenni Marsh
    0

    Hi Rodion, in my experience it doesn't do that. It only returns results if you use the alias of the first item in the list, therefore rendering the function useless. Perhaps this is a bug...

    Jenni

  • Rodion Novoselov 694 posts 859 karma points
    Jan 31, 2012 @ 12:21
    Rodion Novoselov
    0

    It only returns results if you use the alias of the first item in the list

    I have just tried it - it looks to work ok nevertheless.

  • Stefan Kip 1576 posts 4010 karma points c-trib
    Jul 03, 2015 @ 10:25
    Stefan Kip
    0

    Wow, just had a huge mindf*ck when debugging a really old website (umbraco v4.0.3), which had to do with this weird behavior of the ChildrenAsTable method. Thanks for the explanation Rodion!

Please Sign in or register to post replies

Write your reply to:

Draft