Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Grouping, Webparts and Document Types View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 11/4/2011 11:06:48 PM
   
Grouping, Webparts and Document Types
I've got a document type that has 3 fields, ID, Name, Group. The Group field is a dropdown list of items you can select one from per document type. What I'd like to do is display all the Groups and any document types associated within those Groups. Is this possible with a DataList or a Repeater? If so, how? In the past, I've just added several DataLists per Group but think that's kind of tedious.

For instance:

Group 1
Item 1
Item 2
Item 3

Group 2
Item 1
Item 2

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 11/8/2011 12:04:06 AM
   
RE:Grouping, Webparts and Document Types
Isn't there a way to nest a datalist or a repeater in the "Group" datalist or repeater?

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 11/10/2011 2:31:54 AM
   
RE:Grouping, Webparts and Document Types
Hi,

Yes, you can nest repeater or datalist control into transformation of the main repeater or datalist while the nested control can be configured to display all documents which meet some condition:

http://devnet.kentico.com/docs/6_0/controls/cms_listings_and_viewers_using_nested_controls.htm

Thanks,
Miro

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 11/11/2011 1:33:53 AM
   
RE:Grouping, Webparts and Document Types
Miro, the documentation is ok and helped a bit but I think it confused me even more. And its a bit frustrating there are so many different documentation documents. I typically go to the Developer docs right away but they didn't help much.

What I have is a custom document type, with 4 fields, PaintCodeID, PaintCodeText, PaintCodeNote, PaintCodeGroup. PaintCodeGroup is a dropdown list with 5 or so items in them. The items are colors (Red, Green, Yellow, etc.) Each paint code record can have only one PaintCodeGroup. So I want to get all 50 paint codes out and group them by the PaintCodeGroup and display all the PaintCodeText nested within the PaintCodeGroup. I've setup a custom query in the PaintCode document type to SELECT DISTINCT PaintCodeGroup and it returns what I want.

I've also setup a few transformations:

Hierarchical: PaintCodeGroup which looks at the document type MCA.PaintCode and uses transformation PaintCodeGroupName.

ASCX: PaintCodeGroupName which has a single line <h2><%# Eval("PaintCodeGroup") %></h2>

ASCX: PaintCodeNested which has this code:
<cms:CMSDataList ID="PaintCodeNested" runat="server"
ClassNames="MCA.PaintCode"
TransformationName="MCA.PaintCode.PaintCodeNestedResults" RepeatColumns="1" >
</cms:CMSDataList>

ASCX: PaintCodeNestedResults which has this code:
<%# Eval("PaintCodeText") %>
<%# IfEmpty(Eval("PaintCodeNotes"), "", "<br />  <b>Note: </b>" + Eval("PaintCodeNotes"))%>

Then I've added a UniViewer w/Custom Query and specified my query I mentioned above that gets DISTINCT PaintCodeGroup names. I've set the Hierarchical transformation to PaintCodeGroup. I've set the Transformation to PaintCodeNested and set the NestedControslId = PaintCodeNested and left everything else at their defaults and get no results and no errors.

By the way, I'm doing all this from the front end in CMSDesk and the UI. I've also tried the Repeater/DataList combo with no success either. Any further direction would be appreciated!

Thank you!

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 11/21/2011 6:55:16 AM
   
RE:Grouping, Webparts and Document Types
Hi,

What I would do is to use query repeater (repeater with custom query) which will list all of the paint groups with custom query. In transformation of the query repeater I would use nested repeater (not query this time) which will be configured to display all documents of type MCA.PaintCode with where condition saying of which paint group.

Does it make sense?

Example of the transformation used by the main query repeater:

<cc1:CMSRepeater ID="rptEvents" DelayedLoading="true" DataBindByDefault="false" EnableViewState="false" runat="server" Path='/%' TransformationName="MCA.PaintCode.Default" classnames="MCA.PaintCode" HideControlForZeroRows="true" ZeroRowsText="No Events" />

<script runat="server">
protected override void OnInit(EventArgs e) {
rptEvents.WhereCondition = "PaintCodeGroup LIKE '" + Eval("PaintCodeGroup").ToString() + "'";
rptEvents.ReloadData(true);
}
</script>


Of course, main query repeater would need to return PaintCodeGroup column.

Thanks,
Miro

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 11/21/2011 9:36:34 AM
   
RE:Grouping, Webparts and Document Types
So I can use <script> tags in the transformation? Interesting, thank you for the information and tips.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 11/22/2011 8:48:15 PM
   
RE:Grouping, Webparts and Document Types
Worked like a charm, thanks for the assistance.

User avatar
Certified Developer 13
Certified Developer 13
jay@3degreesnorth.com.au - 3/3/2014 9:41:56 PM
   
RE:Grouping, Webparts and Document Types
+1 for this approach. Thanks.

Jay