Repeater or Universal Viewer with "Group By" functionality

Jake Burgy asked on June 1, 2016 03:49

I come across instances very often with clients, where they want to group some data by a field on a page type and display a "jump to" menu at the top, and then group the item display on the page by that field.

For example:


Posts

2016 | 2015 | 2014 | 2013

2016

Post 1

Post 2

Post 3

2015

Post 4

Post 5

Post 6


Et cetera.

I've done a lot of reading on Kentico's documentation, and nothing really points me to what I want, which is a clean way to achieve this just by configuring one or more web parts in the portal engine - no custom code, no inline ASP code or controls.

I just want a one (two?)-level hierarchy - a web part where I can say "From this place in the document tree, for this page type, group by this field, and use this transformation for the parent level and this transformation for the child level." I don't want a "Hierarchical" structure with infinite parents/children, I want exactly one parent/child level - a "GROUP BY" equivalent, if you will.

In the scenario above, I would need two of these web parts - one to display the anchor links at the top, and the other to display the full headers and links underneath them.

Is this even remotely possible? Typically with solutions like these, I will just turn to JavaScript (and output the page fields to JSON), but I really don't like doing things that way. I just don't understand why this is so difficult with Kentico. I struggle with this all the time - so much so that I'm considering writing my own web part to accomplish this - though I'd rather not!

Any insights?

Recent Answers


Chetan Sharma answered on June 1, 2016 12:50

Hi Jake,

  • This is possible out of the box. What you need is a Hierarchical viewer web part.
  • You will ned two level transfromations. Level 0(index starts from 0) will have transfromations to show the data corresponding to year. And level one will have posts.
  • I am assuming you will have two page types in you tree. One for years and the other for posts.
  • Your data will be strcututred with a each year as a node and articles for that year under it. This structure will give hierarchical viewer natural structure to assimilate data.

Would you mind doing a short reading of this article that I picked for you? This shoudl give you a great head start. After this, I can handle all your questions if there are any.

This article was written at the time of v7. However, everything will work for v8 and 9 too.

I hope this helps.

Cheers, Chetan

0 votesVote for this answer Mark as a Correct answer

Jake Burgy answered on June 1, 2016 15:36

Chetan,

Actually, no. We do not have two page types. Our users just fill out a form for a single page type. There is no hierearchy. What I want is to be able to group by a field on the form.

0 votesVote for this answer Mark as a Correct answer

Zachary Perry answered on June 1, 2016 17:17

You might be able to write a custom query to give the data some hierarchy based off the fields. If you can accomplish this then this article might help with using the Hierarchical viewer and a custom query.

0 votesVote for this answer Mark as a Correct answer

Jake Burgy answered on June 1, 2016 18:08

Ah, I was not aware that you can "fake" some of the data in the query - I will try experimenting with this to see if I can get it to work. Thanks!

0 votesVote for this answer Mark as a Correct answer

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