Group by date in TreeDefintion

Topics: Troubleshooting
Aug 24, 2011 at 4:49 PM

I have a datatype containing a date-field that i want to group by. I have the following markup which creates the appropriate year and month folders and all is good.

<Children>
  <DataFolderElements Type="DHF.Calendar.Event" DateFormat="yyyy" FieldGroupingName="StartDate" Display="Auto">
    <Actions>
      <AddDataAction Type="DHF.Calendar.Event" Label="Add Event" />
    </Actions>

    <Children>
      <DataFolderElements DateFormat="MMMM" FieldGroupingName="StartDate" Display="Auto">
        <Actions>
          <AddDataAction Type="DHF.Calendar.Event" Label="Add Event" />
        </Actions>

        <Children>
          <DataElements Type="DHF.Calendar.Event" Label="${C1:Data:DHF.Calendar.Event:Title}" Display="Auto">
            <Actions>
              <EditDataAction Label="Edit" />
              <DeleteDataAction Label="Delete" />
            </Actions>

            <OrderBy>
              <Field FieldName="Title" Direction="ascending"/>
            </OrderBy>
                                
          </DataElements>
        </Children>
      </DataFolderElements>
    </Children>
  </DataFolderElements>
</Children>

Now, i added new property called Category and i want to group by that also, so my xml now looks like this... and bang, nothing works. I can open the tree all the way till my category nodes but they are just empty. No years and no events :(

<Children>
  <DataElements Type="DHF.Calendar.Category" Label="${C1:Data:DHF.Calendar.Category:Title}">
    <Actions>
      <AddDataAction Type="DHF.Calendar.Event" Label="Add Event" />

      <EditDataAction Label="Edit" />
      <DeleteDataAction Label="Delete" />
    </Actions>

    <OrderBy>
      <Field FieldName="Title" Direction="ascending"/>
    </OrderBy>

    <Filters>
      <ParentIdFilter ParentType="DHF.Metadata.Website" ReferenceFieldName="Website" />
    </Filters>

    <Children>
      <DataFolderElements Type="DHF.Calendar.Event" DateFormat="yyyy" FieldGroupingName="StartDate" Display="Auto">
        <Actions>
          <AddDataAction Type="DHF.Calendar.Event" Label="Add Event" />
        </Actions>

        <Children>
          <DataFolderElements DateFormat="MMMM" FieldGroupingName="StartDate" Display="Auto">
            <Actions>
              <AddDataAction Type="DHF.Calendar.Event" Label="Add Event" />
            </Actions>

            <Children>
              <DataElements Type="DHF.Calendar.Event" Label="${C1:Data:DHF.Calendar.Event:Title}" Display="Auto">
                <Actions>
                  <EditDataAction Label="Edit" />
                  <DeleteDataAction Label="Delete" />
                </Actions>

                <OrderBy>
                  <Field FieldName="Title" Direction="ascending"/>
                </OrderBy>

                <Filters>
                  <ParentIdFilter ParentType="DHF.Calendar.Category" ReferenceFieldName="Category" />
                </Filters>
              </DataElements>
            </Children>
          </DataFolderElements>
        </Children>
      </DataFolderElements>
    </Children>
  </DataElements>
</Children>

Content of server-log when trying to expand a category node is

  24-08-2011 18:48
System.InvalidOperationException: No data exist given the data key values
   at Composite.Data.DataFacade.GetDataByUniqueKey(Type interfaceType, DataKeyPropertyCollection dataKeyPropertyCollection) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\Data\DataFacade.cs:line 638
   at Composite.C1Console.Trees.ParentIdFilterNode.FindOwnEntityToken(TreeNode treeNode, EntityToken entityToken, TreeNodeDynamicContext dynamicContext) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\ParentIdFilterNode.cs:line 113
   at Composite.C1Console.Trees.ParentIdFilterNode.FindParentKeyValue(TreeNodeDynamicContext dynamicContext) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\ParentIdFilterNode.cs:line 174
   at Composite.C1Console.Trees.ParentIdFilterNode.CreateUpwardsFilterExpression(ParameterExpression parameterExpression, TreeNodeDynamicContext dynamicContext) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\ParentIdFilterNode.cs:line 191
   at Composite.C1Console.Trees.DataFilteringTreeNode.CreateFilterExpression(ParameterExpression parameterExpression, TreeNodeDynamicContext dynamicContext, IEnumerable`1 filtersToSkip) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\DataFilteringTreeNode.cs:line 54
   at Composite.C1Console.Trees.DataFilteringTreeNode.CreateAccumulatedFilterExpression(ParameterExpression parameterExpression, Type affectedInterfaceType, TreeNodeDynamicContext dynamicContext, IEnumerable`1 filtersToSkip) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\DataFilteringTreeNode.cs:line 80
   at Composite.C1Console.Trees.DataElementsTreeNode.CreateSimpleExpression(TreeNodeDynamicContext dynamicContext) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\DataElementsTreeNode.cs:line 503
   at Composite.C1Console.Trees.DataElementsTreeNode.GetDatas(TreeNodeDynamicContext dynamicContext) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\DataElementsTreeNode.cs:line 486
   at Composite.C1Console.Trees.DataElementsTreeNode.GetEntityTokens(EntityToken childEntityToken, TreeNodeDynamicContext dynamicContext) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\DataElementsTreeNode.cs:line 91
   at Composite.C1Console.Trees.TreeAuxiliaryAncestorProvider.GetParents(IEnumerable`1 entityTokens) in C:\Users\poe\Downloads\compositec1-6706\CompositeC1\Composite\C1Console\Trees\TreeAuxiliaryAncestorProvider.cs:line 105
TreeFacade Error
  24-08-2011 18:48
The tree 'Calendar.xml' failed to return parent entity tokens and are ignored

 

Composite version 2.1.1 build 2.1.4253.30655

Developer
Aug 29, 2011 at 10:24 AM
Edited Aug 29, 2011 at 10:26 AM

Hi burningice,

I tried to reproduce what you describe. I don't know all the details, so I'll go with assumptions if you allow me to :)

As far as I understand:

  1. you had an existing datatype "DHF.Calendar.Event".
  2. you have added a new DataRef field ("Category" pointing to "DHF.Calendar.Event")
  3. you haven't changed the new "Category" field property "Optional" from "No" to "Yes"

If this is your case, all the existing data elements get their category GUID as '0000-....'

As a result, you can't see the elements, nor years nor months

In my experience, when I try to edit such an element in the Data perspective, I get errors and can't edit them.

As a workaround, I can suggest - provided you don't have a lot of Event data elements -

  1. edit "DHF.Calendar.Event_Published.xml" (or whatever it is in /App_data/Composite/DataStores)
  2. replace the "Category" attribute value to one of the GUIDs of an existing category ("DHF.Calendar.Category")
  3. Tools > Restart Server

In my case, it helped.

If this is not your case, please could you give more details?

In the meanwhile, I'll report the error of adding a "required" DataRef field to an exsiting data type...

/Vitaly

 

Aug 29, 2011 at 10:47 AM
Edited Aug 29, 2011 at 10:48 AM

No, its not the case... of course you always have to simplify the situation when trying to describe the bug, and in this case i actually had the Category > Event thing working first, and when i added Category > (year and month) > Event its not working! What i tried to point out was that its not just the Year and month grouping that doesnt work, because if i leave out category and have (year and month) > Event it works also. SO

  • Category > Event - works
  • Category > Year > Month > Event - DOESN'T work
  • Year > Month > Event - works

I mailed Martin a complete working site where this is reproducible.

Developer
Aug 29, 2011 at 10:53 AM

Sorry, I missed one important detail in your XML

    <Filters>
      <ParentIdFilter ParentType="DHF.Metadata.Website" ReferenceFieldName="Website" />
    </Filters>

It seems that it doesn't work when you a apply filter above DataFolderElements.

I'll report that.

Thank you.

 

Aug 29, 2011 at 11:01 AM
Edited Aug 29, 2011 at 11:01 AM

yeah, well, tried to keep it as simple as possible :)

Aug 29, 2011 at 1:46 PM

hi @wysocki,

I have described the similar issue at http://compositec1.codeplex.com/discussions/257748#post662014

I wasn't able to fix my problem after all suggestions.

A website was sent to Martin too.

-Ruslan

Aug 29, 2011 at 1:56 PM

i see... i remember that discussion but also that it suddenly was about 2-3-4 different issues so i didn't really remember what was the essence and the solution to it :)

Developer
Aug 30, 2011 at 9:13 AM
rvesyliv wrote:

I have described the similar issue at http://compositec1.codeplex.com/discussions/257748#post662014

I wasn't able to fix my problem after all suggestions.


Hi Ruslan,

I was able to reproduce your issue, too. To me, both burningice's and yours behave the same way - as burningice put it:

  • Category > Year > Month > Event - DOESN'T work

    The bug has been reproted.

    Thank you for the info

    /Vitaly

  • Sep 13, 2011 at 8:14 AM
    Edited Sep 13, 2011 at 8:14 AM

    The latest checking seems to do the job... since i have a customer who only can run with Official Releases, i've made a patch of the changes that can be applied to C1 version 2.1.1. It can be downloaded from here http://dl.dropbox.com/u/153053/C1%20Bugfix%203596.patch

    You really should look into managing bugfixes in existing releases instead of just "leaving people behind". Its really not that hard managing different branches of code.