Group by Data reference

Topics: General
Apr 4, 2011 at 2:17 PM

Hi

I am creating an application in C1, but im having some problems when displaying data in the content treeview.

My application should display all my Products in an folder grouped by the category. Both Category and Product are Data objects.

How can I make the application display the name field of the Category. and not its GUID?

I have the following code in my custom TreeDefinition:

 

<?xml version="1.0" encoding="UTF-8"?>
<ElementStructure xmlns="http://www.composite.net/ns/management/trees/treemarkup/1.0" xmlns:f="http://www.composite.net/ns/function/1.0">
  <ElementStructure.AutoAttachments>
    <NamedParent Name="Content" Position="Bottom"/>
  </ElementStructure.AutoAttachments>
  <ElementRoot>
    <Children>
      <Element Label="Varekatalog" Id="Product" Icon="folder" OpenedIcon="folder-open">
        <Actions>
          <!--<AddDataAction Label="Add product" Type="luffer.content.Product"/>-->
        </Actions>
        <Children>
          <DataFolderElements Type="luffer.content.Product"  FieldGroupingName="Category"  Display="Compact">
            <Children>
              <DataFolderElements DateFormat="yyyy MMMM" FieldGroupingName="Date" Display="Compact">
                <Actions >
                  <AddDataAction Type="luffer.content.Product" />        
                </Actions>
                <Children>
                  <DataElements Type="luffer.content.Product" Label="${C1:Data:luffer.content.Product:ProductIdent}" Display="Auto">
                    <Actions>
                      <EditDataAction Label="Edit Product" />
                      <DeleteDataAction Label="Delete Product" />
                    </Actions>
                    <!--<Filters>
                  <ParentIdFilter ParentType="Composite.Data.Types.IPage" ReferenceFieldName="PageId" />
                </Filters>-->
                    <OrderBy>
                      <Field FieldName="Date" Direction="descending"></Field>
                    </OrderBy>
                  </DataElements>
                </Children>
              </DataFolderElements>
            </Children>
          </DataFolderElements>
        </Children>
      </Element>
    </Children>
  </ElementRoot>
</ElementStructure>

Thinus

 

Coordinator
Apr 4, 2011 at 2:55 PM

Your outermost <DataFolderElements /> is responsible for writing the folders you see as Guids. Here is a quick 'how to':

1. You should replace this with <DataElements Type="luffer.content.Category" Label="..."  > - this will make your categories show up.

2. This will give you 'all products' inside 'all categories' - you want to limit this. You do this by filtering products, based on the category they are with in. If you uncomment the <Filters /> markup in your xml and change the ParentType to luffer.content.Category and the ReferenceFieldName to "Category" you should have products filtered according to their 'parent folder'

I'm guessing some of you type names here - also the 'Display='auto' may not be what you want etc. but I hope this helps anyway :)

Apr 4, 2011 at 2:59 PM

Thanks Mawtex. it worked perfectly.

 

This is what i ended up with:

<?xml version="1.0" encoding="UTF-8"?>
<ElementStructure xmlns="http://www.composite.net/ns/management/trees/treemarkup/1.0" xmlns:f="http://www.composite.net/ns/function/1.0">
  <ElementStructure.AutoAttachments>
    <NamedParent Name="Content" Position="Bottom"/>
  </ElementStructure.AutoAttachments>
  <ElementRoot>
    <Children>
      <Element Label="Varekatalog" Id="Product" Icon="folder" OpenedIcon="folder-open">
        <Actions>
          <AddDataAction Type="luffer.content.Category" Label="Create Category"/>
        </Actions>
        <Children>
          <DataElements Type="luffer.content.Category" Icon="folder" OpenedIcon="folder-open">
            <Actions>
              <AddDataAction Label="Add Product" Type="luffer.content.Product"/>
              <EditDataAction Label="Edit Category"/>
              <DeleteDataAction Label="Delete Category"/>
            </Actions>
            <Children>
              <DataFolderElements Type="luffer.content.Product" FieldGroupingName="Date" DateFormat="yyyy MMMM" Display="Compact">
                <Children>
                  <DataElements Type="luffer.content.Product">
                    <Actions>
                      <EditDataAction Label="Edit Product"/>
                      <DeleteDataAction Label="Delete Product"/>
                    </Actions>
                    <Filters>
                      <ParentIdFilter ReferenceFieldName="Category" ParentType="luffer.content.Category"/>
                    </Filters>
                  </DataElements>

                </Children>
              </DataFolderElements>


            </Children>
          </DataElements>
        </Children>
      </Element>
    </Children>
  </ElementRoot>
</ElementStructure>

Apr 11, 2011 at 2:45 PM

Im having another issue concerning treedefinitions.

I'm supposed to create a "deep-level" tree with 10 levels or even more. I can't use enay kind of grouping argument as there are no rules for where i put a dataelement except from the fact that I click on that dataelement I want to be the parent element.

Isn't this correct? or has anyone EVER CREATED SUCH A TREE DEFINITION with say just 5 levels? 

Anyone?