Results 1 to 10 of 10

Thread: Multi select records i a dynamic cDbCJGrid/cDbCJGridPromptList

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Join Date
    Feb 2009
    Location
    Perth, Western Australia
    Posts
    1,403

    Default Re: Multi select records i a dynamic cDbCJGrid/cDbCJGridPromptList

    Hi Keith,

    Quote Originally Posted by Keith Nikolaison View Post
    Are you looking for something like this thread ?
    Not exactly. I am looking for non-dataware (cCJGridColumn). I currently have two solutions that solve this problem but not sure which is best.

    The first updates and saves the data source directly before redrawing the previously selected column.

    Code:
    Object oCJGridColumn4 is a cCJGridColumn
        Set piWidth To 100
        Set psCaption To "Select"
        Set peIconAlignment To xtpAlignmentIconCenter
        Set peHeaderAlignment To xtpAlignmentCenter
        Set pbCheckbox To True
        Set pbEditable To True
       
        // force the use of values that are different from the defaults of true/false
        
        Set psCheckboxTrue To 'Y'
        Set psCheckboxFalse To 'N'
    
        // property to track the currently checked row 
        
        Property Integer piTrack_Selected_Row       -1
    
    
        // Check_Track_Selected_Row:
        // Reset any previously selected row.
        //
        Function Check_Track_Selected_Row String sNewValue Returns Boolean
            tDataSourceRow[] ltrgData
            Handle ohRow ohItem ohMetrics      
            Integer iSelectedRow iRow
            String sUnchecked
            Boolean bUpdated
    
            Get CheckedStateToValue False To sUnchecked
    
            Get piTrack_Selected_Row To iRow
            Get SelectedRow Of (phoDataSource(Self)) To iSelectedRow
            If (iRow <> -1 AND iRow <> iSelectedRow) Begin
                Move (True) To bUpdated
                
                Get DataSource Of (phoDataSource(Self)) To ltrgData
                Move sUnchecked To ltrgData[iRow].sValue[(piColumnId(Self))]
                Set pDataSource Of (phoDataSource(Self)) To ltrgData
    
                Get phoReportRow To ohRow
                Get phoReportRecordItem To ohItem
                Get phoReportRecordItemMetrics To ohMetrics  
                Send DrawCell ohRow ohItem ohMetrics iRow sUnchecked
            End
            Else Move (False) To bUpdated
    
            If (sNewValue = sUnchecked) Set piTrack_Selected_Row To -1
            Else Set piTrack_Selected_Row To iSelectedRow
            
            Function_Return bUpdated
        End_Procedure // Check_Track_Selected_Row
    
    
        // OnEndEdit:
        // After our edit update what's being tracked                
        //
        Procedure OnEndEdit String sOldValue String sNewValue
            Boolean bUpdated
    
            Get Check_Track_Selected_Row sNewValue To bUpdated
        End_Procedure // OnEndEdit
    
    End_Object // oCJGridColumn4
    The second saves any changes to the current row before updating the data source and using ReInitializeData to refresh the grid.

    Code:
    Object oCJGridColumn4 is a cCJGridColumn
        Set piWidth To 100
        Set psCaption To "Select"
        Set pbCheckbox To True
        Set peIconAlignment To xtpAlignmentIconCenter
        Set pbEditable To True
        Set peHeaderAlignment To xtpAlignmentCenter
        
        // force the use of values that are different from the defaults of true/false
        
        Set psCheckboxTrue To 'Y'
        Set psCheckboxFalse To 'N'
    
        // property to track the currently checked row 
        
        Property Integer piTrack_Selected_Row       -1
    
    
        // Check_Track_Selected_Row:
        // Reset any previously selected row.
        //
        Function Check_Track_Selected_Row String sNewValue Returns Boolean
            tDataSourceRow[] ltrgData
            tDataSourceRow ltData
            Integer iSelectedRow iRow
            Boolean bOk bCancel
            String sUnchecked
    
            Move (True) To bOk
            Get CheckedStateToValue False To sUnchecked
            
            Get piTrack_Selected_Row To iRow
            Get SelectedRow Of (phoDataSource(Self)) To iSelectedRow
            If (iRow <> -1 AND iRow <> iSelectedRow) Begin
                Get SaveSelectedRow To bCancel
                If (NOT(bCancel)) Begin
                    Get DataSource Of (phoDataSource(Self)) To ltrgData
                    Move sUnchecked To ltrgData[iRow].sValue[(piColumnId(Self))]
                    Send ReInitializeData ltrgData False
                End
                Else Begin
                    Move (False) To bOk
                    Get pCurrentDataSourceRow Of (phoDataSource(Self)) To ltData
                    Move sUnchecked To ltData.sValue[(piColumnId(Self))]
                    Set pCurrentDataSourceRow Of (phoDataSource(Self)) To ltData
                End
            End
    
            If (bOk) Begin
                If (sNewValue = sUnchecked) Set piTrack_Selected_Row To -1
                Else Set piTrack_Selected_Row To iSelectedRow
            End
    
            Function_Return bOk
        End_Procedure // Check_Track_Selected_Row
    
    
        // OnEndEdit:
        // After our edit update what's being tracked                
        //
        Procedure OnEndEdit String sOldValue String sNewValue
            Boolean bOk
    
            Get Check_Track_Selected_Row sNewValue To bOk
        End_Procedure // OnEndEdit
    
    End_Object // oCJGridColumn4
    Last edited by Clive Richmond; 17-May-2017 at 12:31 AM. Reason: ReInitializeData version could allow 2 rows to be selected at the same time
    Kind regards,

    Clive Richmond
    Triumph Business Systems Pty Ltd
    www.triumph.com.au

Posting Permissions

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