How to create multi-level grouping

  • 24 February 2022
  • 0 replies
  • 0 views





 








How to create multi-level grouping





























This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.






LEGACY/ARCHIVED CONTENT


This article has been archived, and/or refers to legacy products, components or features. The content in this article is offered "as is" and will no longer be updated. Archived content is provided for reference purposes only. This content does not infer that the product, component or feature is supported, or that the product, component or feature will continue to function as described herein.




Objective



Creating multi-level grouping using a SmartObject and a Tree control.

Before You Begin



Start by creating a SmartObject and adding data to it in a specific manner to allow the tree control to display the content in a multi-level grouping format.



Group Stucture Format



  Country



     States



          City



                District



 



Grouping Structure with content



  South Africa



      Gauteng



           Johannesburg



                 Randburg



How-to Steps



1. When creating the SmartObject that will contain the data, the SmartObject must be designed and data has to be added to it in a specific manner.



You will need to make sure that your SmartObject contains the below three properties when creating it:





  • ID : Autonumber


  • Type : Text


  • ParentID : Text OR Number




 



2. After your SmartObject has been created, the data added to it also needs to be added in a specific manner. The ID will be created automatically as it is set to an autonumber however, the Type and ParentID need to be specified.



When you specify the Type you can add the text that you need it to be, the ParentID will be the group identifier for the Type. 

For example: If I want my grouping to look like below:



Group Names



    Group 1



        User 1



        User 2



    Group 2



        User A



 



3. I will need to add the First Type which would be "Group Names." This will then have a ParentID of "0" (zero) as zero is the indicator of the parent in the tree control data source. The Second Type "Group 1" will then need the Type:"Group Names" ID value set to be the ParentID for Type:"Group 1" which would mean that Group 1 would then become a child of the parent group. This will result in the below structure:



TreeSMO.png



 



4. After your SmartObject is set up and contains data you can simply bind it to the Tree control as its data source as below:



TreeDS.png



5. Then save, finish and Run your view. The data will then be displayed like the results below:



TreeR.png



 



Please also see K2 Documentation - Tree Control










0 replies

Be the first to reply!

Reply