Results 1 to 6 of 6

Thread: ccjGrid-TreeView ???

  1. #1
    Join Date
    Mar 2009
    Location
    São Paulo Brazil
    Posts
    162

    Default ccjGrid-TreeView ???

    Hi folks
    Did Someone build a ReportControl Object like the picture ?
    Click image for larger version. 

Name:	ReportControl-Treeview.png 
Views:	246 
Size:	15.8 KB 
ID:	13085
    I would like to use "ccjGrid-TreeView" or something like that.
    DF 18.0 - CJ 16.3.1
    Regards

  2. #2
    Join Date
    Feb 2009
    Location
    Rio do Sul - SC
    Posts
    286

    Default Re: ccjGrid-TreeView ???

    Ezequiel,

    Take a look at the GroupedGrid class.
    https://support.dataaccess.com/Forum...ht=groupedgrid

    HTH.
    []'s
    Clayton Schirmer

  3. #3
    Join Date
    Mar 2009
    Location
    São Paulo Brazil
    Posts
    162

    Default Re: ccjGrid-TreeView ???

    HI Clayton...
    I saw this thread, but I couldn't makes work with multi-level, just one.
    So I am still looking for a solution...
    Thank you
    Ezequiel

  4. #4
    Join Date
    Feb 2009
    Location
    UK
    Posts
    826

    Default Re: ccjGrid-TreeView ???

    Hi Ezequiel

    Try the attached class. It has support for images added. I have just merged some of the changes I have that have not made it into public release yet.

    cSigCJReportControl.pkg

    I have not compiled or tested this.


    1. You will need to added code in OnCreate to load the images
    2. Set the column style to eRC_Image
    3. Code OnImagePath to return the image ID


    Code:
                    Procedure OnCreate
                        Integer iImageID
    
                        //Add Icons to image manager
                        Get AddImage of ghoSigCjGlobalSetting (psBitmapPath(phoWorkspace(ghoApplication)) + "\Round_Green_Tick_16.ico") 0 OLExtpImageNormal to iImageID
                        Set piIcon_Allowed to iImageID
    
                        Get AddImage of ghoSigCjGlobalSetting (psBitmapPath(phoWorkspace(ghoApplication)) + "\Round_Red_Minus_16.ico") 0 OLExtpImageNormal to iImageID
                        Set piIcon_Denied to iImageID
    
                        Get AddImage of ghoSigCjGlobalSetting (psBitmapPath(phoWorkspace(ghoApplication)) + "\Round_Grey_Minus_16.ico") 0 OLExtpImageNormal to iImageID
                        Set piIcon_Disabled to iImageID
    
                        Forward Send OnCreate
    
                        Set ComAllowColumnReOrder to False
                        Set ComAllowColumnRemove to False
                        Set ComRecordsTreeFilterMode to OLExtpReportFilterTreeByParentAndChildren
                    End_Procedure
    
                    //---------------------------------------------------------------------
    
                    Procedure OnDefine_Columns
                        Send Add_Report_Column "ID"              0 eRC_Integer eRC_Standard ""
                        Send Add_Report_Column "Component"     200 eRC_String  eRC_Standard ""
                        Send Add_Report_Column "Access"         50 eRC_String  eRC_Image    ""
                        Send Add_Report_Column "Description"   200 eRC_String  eRC_Standard ""
                    End_Procedure
    
                    //-------------------------------------------------------------
    
                    //Pass back image info based on report column value
                    Procedure OnImagePath Integer iColumn Integer ByRef iImageId String ByRef sValue
                        Get piIcon_Denied to iImageId
                        If (sValue = "X") Get piIcon_Disabled to iImageId
                        If (sValue = "Y") Get piIcon_Allowed  to iImageId
                    End_Procedure

    You can also set one of the columns to be a tree column. peDb_Type must be eRC_db_Text for this to work as you will need to manual load the data and create the child records. Only the parent most records are loaded via OnPrepare_RowData, all the child records are created in OnCreateRowItem. Again, this example code has just been hacked from an application - not compiled or tested, but should be enough for you to adapt for your application. All of the data is preloaded into a recursive structure in OnOpen_DataSource

    Code:
    Struct tdUser_Security
        Integer iComponent_URN
        String  sAllow_Access
        String  sComponent_Name
        String  sComponent_Description
        tdUser_Security[] taChild_Components
    End_Struct
    Code:
                    //Set the Tree Column
                    Procedure OnCreateColumn Integer iColumn Handle hoCol
                        If (iColumn = 1) Begin
                            Set ComTreeColumn of hoCol to True
                        End
                    End_Procedure
    
                    //Add Icon column
                    Procedure Add_Item_Icon Handle hoRecord String sValue
                        Handle  hoItem
                        Integer iImageId
                        Variant vItem vImage
    
                        Get phoReportRecordItem to hoItem
                        Get ComAddItem of hoRecord sValue to vItem
                        Set pvComObject of hoItem to vItem
    
                        Get piIcon_Denied to iImageId
                        If (sValue = "X") Get piIcon_Disabled to iImageId
                        If (sValue = "Y") Get piIcon_Allowed  to iImageId
    
                        Get ImageFromId of ghoSigCjGlobalSetting iImageId to vImage
                        If (not(IsNullComObject(vImage))) Begin
                            Set ComAlignment   of hoItem to OLExtpAlignmentIconCenter
                            Set ComIcon        of hoItem to iImageId
                            Set ComCaption     of hoItem to " "     // This stops the value from being shown
                        End
                    End_Procedure
    
                    //Add child items to a report item
                    Procedure Add_Child_Records Handle hoRecords tdUser_Security[] taGrid_Data
                        Handle hoRecord hoChild_Records
                        Variant vItem
                        Integer iIndex iMax
    
                        Get Create U_cSigCJComReportRecord to hoRecord
    
                        Move (SizeOfArray(taGrid_Data) - 1) to iMax
                        For iIndex from 0 to iMax
                            Set pvComObject of hoRecord to (ComAdd(hoRecords))
    
                            Get ComAddItem of hoRecord taGrid_Data[iIndex].iComponent_ID          to vItem
                            Get ComAddItem of hoRecord taGrid_Data[iIndex].sComponent_Name        to vItem
                            Send Add_Item_Icon hoRecord taGrid_Data[iIndex].sAllow_Access
                            Get ComAddItem of hoRecord taGrid_Data[iIndex].sComponent_Description to vItem
    
                            Set ComTag of hoRecord to taGrid_Data[iIndex].iComponent_URN
    
                            //CAUTION : Recursive call : CAUTION
                            If (SizeOfArray(taGrid_Data[iIndex].taChild_Components) > 0) Begin
                                Get Create U_cSigCJComReportRecords to hoChild_Records
                                    Set pvComObject of hoChild_Records to (ComChilds(hoRecord))
                                    Send Add_Child_Records hoChild_Records taGrid_Data[iIndex].taChild_Components
                                Send Destroy of hoChild_Records
                            End
                        Loop
    
                        Send Destroy of hoRecord
                    End_Procedure
    
                    //Use OnCreateRowItem to add additional child records. We don't
                    //need to do this every time the event is called, simply once
                    //per row so we wait until the passed column is the last one in
                    //the row (iColumn = piColumn_Count)
                    Procedure OnCreateRowItem Integer iColumn Handle hoItem String sValue
                        Handle hoChild_Records
                        Integer iIndex
                        tdUser_Security[] taGrid_Data
    
                        If (iColumn = piColumn_Count(Self)) Begin
                            Get piCh_No to iIndex
                            Decrement iIndex    //Need to decrement as it has already been incremented
                            Get ptaGrid_Data to taGrid_Data
                            If (SizeOfArray(taGrid_Data[iIndex].taChild_Components) > 0) Begin
                                Get Create U_cSigCJComReportRecords to hoChild_Records
                                    Set pvComObject of hoChild_Records to (ComChilds(phoReportRecord(Self)))
                                    Send Add_Child_Records hoChild_Records taGrid_Data[iIndex].taChild_Components
                                Send Destroy of hoChild_Records
                            End
                        End
                    End_Procedure
    Ian Smith
    (Member of the SigCj project)

  5. #5
    Join Date
    Mar 2009
    Location
    São Paulo Brazil
    Posts
    162

    Default Re: ccjGrid-TreeView ???

    Thank you very much Ian..
    I will to test now !
    Regards

    Quote Originally Posted by Ian Smith View Post
    Hi Ezequiel

    Try the attached class. It has support for images added. I have just merged some of the changes I have that have not made it into public release yet.

    cSigCJReportControl.pkg

    I have not compiled or tested this.


    1. You will need to added code in OnCreate to load the images
    2. Set the column style to eRC_Image
    3. Code OnImagePath to return the image ID


    Code:
                    Procedure OnCreate
                        Integer iImageID
    
                        //Add Icons to image manager
                        Get AddImage of ghoSigCjGlobalSetting (psBitmapPath(phoWorkspace(ghoApplication)) + "\Round_Green_Tick_16.ico") 0 OLExtpImageNormal to iImageID
                        Set piIcon_Allowed to iImageID
    
                        Get AddImage of ghoSigCjGlobalSetting (psBitmapPath(phoWorkspace(ghoApplication)) + "\Round_Red_Minus_16.ico") 0 OLExtpImageNormal to iImageID
                        Set piIcon_Denied to iImageID
    
                        Get AddImage of ghoSigCjGlobalSetting (psBitmapPath(phoWorkspace(ghoApplication)) + "\Round_Grey_Minus_16.ico") 0 OLExtpImageNormal to iImageID
                        Set piIcon_Disabled to iImageID
    
                        Forward Send OnCreate
    
                        Set ComAllowColumnReOrder to False
                        Set ComAllowColumnRemove to False
                        Set ComRecordsTreeFilterMode to OLExtpReportFilterTreeByParentAndChildren
                    End_Procedure
    
                    //---------------------------------------------------------------------
    
                    Procedure OnDefine_Columns
                        Send Add_Report_Column "ID"              0 eRC_Integer eRC_Standard ""
                        Send Add_Report_Column "Component"     200 eRC_String  eRC_Standard ""
                        Send Add_Report_Column "Access"         50 eRC_String  eRC_Image    ""
                        Send Add_Report_Column "Description"   200 eRC_String  eRC_Standard ""
                    End_Procedure
    
                    //-------------------------------------------------------------
    
                    //Pass back image info based on report column value
                    Procedure OnImagePath Integer iColumn Integer ByRef iImageId String ByRef sValue
                        Get piIcon_Denied to iImageId
                        If (sValue = "X") Get piIcon_Disabled to iImageId
                        If (sValue = "Y") Get piIcon_Allowed  to iImageId
                    End_Procedure

    You can also set one of the columns to be a tree column. peDb_Type must be eRC_db_Text for this to work as you will need to manual load the data and create the child records. Only the parent most records are loaded via OnPrepare_RowData, all the child records are created in OnCreateRowItem. Again, this example code has just been hacked from an application - not compiled or tested, but should be enough for you to adapt for your application. All of the data is preloaded into a recursive structure in OnOpen_DataSource

    Code:
    Struct tdUser_Security
        Integer iComponent_URN
        String  sAllow_Access
        String  sComponent_Name
        String  sComponent_Description
        tdUser_Security[] taChild_Components
    End_Struct
    Code:
                    //Set the Tree Column
                    Procedure OnCreateColumn Integer iColumn Handle hoCol
                        If (iColumn = 1) Begin
                            Set ComTreeColumn of hoCol to True
                        End
                    End_Procedure
    
                    //Add Icon column
                    Procedure Add_Item_Icon Handle hoRecord String sValue
                        Handle  hoItem
                        Integer iImageId
                        Variant vItem vImage
    
                        Get phoReportRecordItem to hoItem
                        Get ComAddItem of hoRecord sValue to vItem
                        Set pvComObject of hoItem to vItem
    
                        Get piIcon_Denied to iImageId
                        If (sValue = "X") Get piIcon_Disabled to iImageId
                        If (sValue = "Y") Get piIcon_Allowed  to iImageId
    
                        Get ImageFromId of ghoSigCjGlobalSetting iImageId to vImage
                        If (not(IsNullComObject(vImage))) Begin
                            Set ComAlignment   of hoItem to OLExtpAlignmentIconCenter
                            Set ComIcon        of hoItem to iImageId
                            Set ComCaption     of hoItem to " "     // This stops the value from being shown
                        End
                    End_Procedure
    
                    //Add child items to a report item
                    Procedure Add_Child_Records Handle hoRecords tdUser_Security[] taGrid_Data
                        Handle hoRecord hoChild_Records
                        Variant vItem
                        Integer iIndex iMax
    
                        Get Create U_cSigCJComReportRecord to hoRecord
    
                        Move (SizeOfArray(taGrid_Data) - 1) to iMax
                        For iIndex from 0 to iMax
                            Set pvComObject of hoRecord to (ComAdd(hoRecords))
    
                            Get ComAddItem of hoRecord taGrid_Data[iIndex].iComponent_ID          to vItem
                            Get ComAddItem of hoRecord taGrid_Data[iIndex].sComponent_Name        to vItem
                            Send Add_Item_Icon hoRecord taGrid_Data[iIndex].sAllow_Access
                            Get ComAddItem of hoRecord taGrid_Data[iIndex].sComponent_Description to vItem
    
                            Set ComTag of hoRecord to taGrid_Data[iIndex].iComponent_URN
    
                            //CAUTION : Recursive call : CAUTION
                            If (SizeOfArray(taGrid_Data[iIndex].taChild_Components) > 0) Begin
                                Get Create U_cSigCJComReportRecords to hoChild_Records
                                    Set pvComObject of hoChild_Records to (ComChilds(hoRecord))
                                    Send Add_Child_Records hoChild_Records taGrid_Data[iIndex].taChild_Components
                                Send Destroy of hoChild_Records
                            End
                        Loop
    
                        Send Destroy of hoRecord
                    End_Procedure
    
                    //Use OnCreateRowItem to add additional child records. We don't
                    //need to do this every time the event is called, simply once
                    //per row so we wait until the passed column is the last one in
                    //the row (iColumn = piColumn_Count)
                    Procedure OnCreateRowItem Integer iColumn Handle hoItem String sValue
                        Handle hoChild_Records
                        Integer iIndex
                        tdUser_Security[] taGrid_Data
    
                        If (iColumn = piColumn_Count(Self)) Begin
                            Get piCh_No to iIndex
                            Decrement iIndex    //Need to decrement as it has already been incremented
                            Get ptaGrid_Data to taGrid_Data
                            If (SizeOfArray(taGrid_Data[iIndex].taChild_Components) > 0) Begin
                                Get Create U_cSigCJComReportRecords to hoChild_Records
                                    Set pvComObject of hoChild_Records to (ComChilds(phoReportRecord(Self)))
                                    Send Add_Child_Records hoChild_Records taGrid_Data[iIndex].taChild_Components
                                Send Destroy of hoChild_Records
                            End
                        End
                    End_Procedure

  6. #6
    Join Date
    Mar 2009
    Location
    São Paulo Brazil
    Posts
    162

    Default Re: ccjGrid-TreeView ???

    Ian..

    Works like charm


    Thank you !


    Regards


    Ezequiel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •