Universal Hierarchy Viewer with Custom Table Data

Guido Paolano asked on March 3, 2018 23:15

I am trying to display data from custom tables in a hierarchy using the universal viewer with custom data. I couldn't get it to show, so I scaled back to just the following query and two basic generated transforms. I checked load hierarchical data and set the ItemID, ParentID and Level columns in the web part set up. Unfortunately, doesn't show data. However, when I just use it like a non-hierarchical repeater, it does show up.

SELECT 1 AS ItemID, NULL as ParentID, 0 as Level, 'Default' as [FolderName], null as DocumentName

UNION

SELECT 2 as ItemID, 1 AS ParentID, 1 as Level, null, 'File' as [DocumentName] 

Recent Answers


David te Kloese answered on March 5, 2018 10:34

Hi,

So which Web Part are you using? You mention

  • Universal Hierarchy Viewer with Custom Table Data
  • universal viewer with custom data

But those don't exist...

I tried doing as much as what you described and when I use the following I get working data:

Web Part: Universal Viewer With Custom Query properties:

  • ID column: ItemID
  • ParentID Column: ParentID
  • Level column: Level
  • Load hierarchical data: checked
  • Use default hierarchical order: checked

Query:

SELECT 1 AS ItemID, NULL as ParentID, 0 as Level, 'Default' as [FolderName], null as DocumentName
UNION
SELECT 2 as ItemID, 1 AS ParentID, 1 as Level, null, 'File' as [DocumentName]
ORDER BY ##ORDERBY##

Hierarchical transformation:

Image Text

Transformation (text/XML): (I've set both the same for demostration)

<p>
 ItemID - {%ItemID%};
 ParentID - {%ParentID%};
 Level - {%Level%};
 Folder - {%FolderName%};
 Document - {%DocumentName%};
<p>

Result https://content.screencast.com/users/DavidTK/folders/Jing/media/d3088113-333a-4b6d-b3f0-c1e5194c5fc9/2018-03-05_1027.png

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 5, 2018 13:59

Keep in mind if you are using the "class" feature of hierarchy transformation, you should adjust your custom query to also return as "classname" column with the right code name, you also seem to be missing the nodeorder field which you also need. You can use the row() over (partition by x order by y) type of SQL logic

0 votesVote for this answer Mark as a Correct answer

Guido Paolano answered on March 5, 2018 15:15

Thank you for the answers. Yes, I am using the Universal Viewer with Custom Query, I just wanted to stress that I wasn't pulling in page data, but custom data.

Do you know if the Hierarchy functions of that viewer require jQuery?

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 5, 2018 15:28

I know you aren't pulling page data, however how the hierarchy transformations work is it takes the NodeLevel, NodeOrder, ItemID, ParentID, and the "ClassName" of the current row and matches it with the transformation that applies (if no Class Name, then only "All" typed transformations will be applied).

If page type is set to "All" in your hierarchy transformation item then you're fine, just wanted to specify in case you set a page type (say CMS.Folder) on the hierarchy transformation, then your query must return a column "ClassName" and the value of "CMS.Folder" for that transformation to kick in.

Anyway, based on what you have, you probably just have the Universal Viewer misconfigured, or it's complaining because you are missing an Order field (but probably not), can you screenshot the settings you have for the hierarchy viewer? And one of the Hierarchy Transformation you're using?

0 votesVote for this answer Mark as a Correct answer

Guido Paolano answered on March 5, 2018 18:59

Thank you both for the answers. I tried my code on another installation that I use to test and it worked as expected. I think somehow our javascript/jQuery isn't firing, and even if it isn't directly affecting the universal viewer, it might be indirectly.

Thank you again. This is a big help.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.