1 Reply Latest reply: Apr 10, 2013 9:23 PM by blossoms_bubbles RSS

    Access GroupingCollection2 's variable newCollection

    blossoms_bubbles Community Member

      Hello,

       

      I need to group data based on date. The groups will be Today, Yesterday, Tomorrow, Next Week, Last Week etc instead of actual date values.

       

      To do this I have added logic in groupingFunction of GroupingField.

       

      But the problem is same group is added more than once with different data. E.g Group "Last Week" appears twice in my Advanced Datagrid and each of these groups is having different data.

       

      So I thought that once the groups are formed I will take loop on newCollection variable of GroupingCollection2 which gives me all the created groups. and then check if all same group already exists then combine the children of the same groups.

      But I feel this is a sort of workaround. Moreover newCollection variable is a private variable so i cant access it.

       

      Can anyone please guide me how I can do this in proper and efficient way?

       

      Thanks in advance.

        • 1. Re: Access GroupingCollection2 's variable newCollection
          blossoms_bubbles Community Member

          Hi,

           

          I found that in GroupingCollection2 there is a method named buildGroups() where the logic of grouping lies. To solve my issue, I added the code in this method. I did monkey patching for GroupingCollection2.

           

          I added logic which checks if the currentGroup already exists in newCollection or not. If not then only it is added to newCollection otherwise the currentData is added to the existing group.

           

          I have done this but still I am not sure that is this the best way to do this or not.

           

          Please let me know if any other solution is there.

           

          Thanks...