Forums / SmartComponent Library - Developer Forum / SmartDataBrwoser - row multi select

SmartDataBrwoser - row multi select

11 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    01 Jun 2020
    Link to this post
    You can use the EnableMutliSelection to setup the browser for allowing multiple rows to be selected. Is there a way in SCL to get all these rows to be deleted when clicking the DELETE tool?

     /**
         * Purpose: Enabels selection of multiple rows in the SmartDataBrowser
         * Notes:   It is required to set DeselectRowsOnActivate = FALSE when using this
         *          method
         */
        METHOD PUBLIC VOID EnableMultiSelection ():
            THIS-OBJECT:SetMultiSelection (TRUE) .
        END METHOD .
  2. Mike Fechner
    Mike Fechner avatar
    263 posts
    Registered:
    14 Sep 2016
    Answered
    01 Jun 2020 in reply to Roger Blanchard
    Link to this post
    I don't think there's something that does not require some code. This here is from the Business Entity Designer based on a temp-table adapter:

        /*------------------------------------------------------------------------------
            Purpose: Event handler for the BeforeDeleteRecord event of the
            Notes:   Implements multi-selection deletion
            @param sender The reference to the object that raised the event
            @param e The BeforeDeleteRecordEventArgs with the data for this event
        ------------------------------------------------------------------------------*/
        METHOD PRIVATE VOID smartTempTableAdapter1_BeforeDeleteRecord (sender AS System.Object,
                                                                       e AS BeforeDeleteRecordEventArgs):

            DEFINE VARIABLE cFieldName AS CHARACTER NO-UNDO.

            smartUpdatableBrowser1:ActiveRow:Selected = TRUE .

            e:Cancel = TRUE .

            {Consultingwerk/foreach.i UltraGridRow oRow in smartUpdatableBrowser1:Selected:Rows}
                cFieldName = UNBOX (oRow:Cells["FieldName":U]:Value) .

                {&_proparse_ prolint-nowarn(findnoerror)}
                FIND eField WHERE eField.FieldName = cFieldName .

                DELETE eField .
            END.

            CATCH err AS Progress.Lang.Error :
                ErrorHelper:ShowErrorMessage (err) .
            END CATCH.

            FINALLY:
                smartUpdatableBrowser1:Selected:Rows:Clear() .
                smartTempTableAdapter1:RetrieveData() .
            END FINALLY.

        END METHOD.

    If you're using a business entity adapter, similar code should work, like in a method in the DatasetController class the code should look very similar - you just have to submit the changes when done. And don't forget to turn on TRACKING-CHANGES.

    The Consultingwerk.Windows.Util.UltraGridSelectedRowsHelper:CopySelectedRowsToProDataset method may also be useful. It copies the selected rows into a copy of the ProDataset. Those could then also be deleted.

  3. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    01 Jun 2020 in reply to Mike Fechner
    Link to this post
    Thanks Mike...I will take a look at this.
  4. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    01 Jun 2020 in reply to Mike Fechner
    Link to this post
    That seems to work. The only issue is when you set e:Cancel = TRUE that will throw an exception. I set the e:CancelMessage to just say multiple rows deleted but it just still looks like an exception.

    DO ON ERROR UNDO, THROW:
       
       IF NOT THIS-OBJECT:LabelItemBrowser:Selected:Rows:Count GT 0 THEN // nothing to do
             RETURN. 
      
       ASSIGN
        oDatasetController = CAST (THIS-OBJECT:LabelItemAdapter:DatasetController,
                                    Osprey.Host.LabelHdr.LabelHdrDatasetController
                                 ). 
                                
       IF VALID-OBJECT (oDatasetController) THEN
       DO:
        oDatasetController:LabelItemDelete(THIS-OBJECT:LabelItemBrowser:Selected:Rows).
        /* Roger Blanchard / Osprey Retail Systems Jun 1, 2020
         If we are here our delete must have worked so lets cancel the default
         DeleteRecord logic
        */
        e:Cancel   = TRUE.
        e:CancelMessage = "Multiple Rows Deleted".
       END.
       
        CATCH err AS Progress.Lang.Error :
         LogManagerWrapper:WriteError(err).
                 ErrorHelper:ShowErrorMessage (err).
             END CATCH.
        
        
      END.  



  5. Mike Fechner
    Mike Fechner avatar
    263 posts
    Registered:
    14 Sep 2016
    01 Jun 2020 in reply to Roger Blanchard
    Link to this post
    Out of curiosity. What does your LogManagerWrapper do that our Consultingwerk.Util.LogManager class does not? 

    Have you tried not setting the CancelMessage? The Updatable Browser is not going to show a message when there is no message:

            CATCH cancelex AS Consultingwerk.Exceptions.CancelException:
                /* When there's a message with a Cancel Exception, show it */
                IF cancelex:NumMessages > 0 THEN
                    THIS-OBJECT:DisplayError (cancelex, SmartComponentLibraryCustomizer:SmartViewerControl_UnableToCreateRecord) .


                THIS-OBJECT:DisableFields () .
            END CATCH.

  6. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    01 Jun 2020 in reply to Mike Fechner
    Link to this post
    >> Out of curiosity. What does your LogManagerWrapper do that our Consultingwerk.Util.LogManager class does not? 

    We roll the log files and keep x number of days based on a parameter.

    We are not using the Updatable Browser just the Smart Data Browser. If I don't set the CancelMessage then I get a default message "Consultingwerk.Exceptions.CancelException.

    DeleteRow Consultingwerk.SmartComponents.Base.SmartDatasetAdapter at line 2002  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Base\SmartDatasetAdapter.r)
    DeleteRecord Consultingwerk.SmartComponents.Base.SmartViewerControl at line 2300  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Base\SmartViewerControl.r)
    HandleToolClick Consultingwerk.SmartComponents.Implementation.SmartToolbarStateController at line 1008  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Implementation\SmartToolbarStateController.r)
    OnToolClick Consultingwerk.SmartComponents.Implementation.SmartToolbarController at line 2017  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Implementation\SmartToolbarController.r)
    OnToolClick Osprey.CustomClasses.SmartComponents.OspreyToolbarController at line 496  (C:\ProgressWrk\OspreyVer117102\OspreyFramework\Osprey\CustomClasses\SmartComponents\OspreyToolbarController.r)
    SetupApp.p at line 211  (C:\ProgressWrk\OspreyVer117102\OspreyHost\client\host\SetupApp.r)
    C:\ProgressWrk\OspreyVer117102\OspreyHost\client\host\OspreyHost.p at line 531  (C:\ProgressWrk\OspreyVer117102\OspreyHost\client\host\OspreyHost.r)
    adecomm/_runcode.p at line 678  (adecomm/_runcode.r)
    C:\Progress\OpenEdge\oeide\eclipse\plugins\com.openedge.pdt.debug.core_11.7.5.00\abl\_debuglauncher.p at line 100  (C:\Progress\OpenEdge\oeide\eclipse\plugins\com.openedge.pdt.debug.core_11.7.5.00\abl\_debuglauncher.p)


    Shown by:
    ShowErrorMessage Consultingwerk.Util.ErrorHelper at line 2331  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\Util\ErrorHelper.r)
    ShowErrorMessage Consultingwerk.Util.ErrorHelper at line 2269  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\Util\ErrorHelper.r)
    DisplayError Consultingwerk.SmartComponents.Base.SmartViewerControl at line 5317  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Base\SmartViewerControl.r)
    DisplayError Osprey.CustomClasses.SmartComponents.OspreyViewerControl at line 88  (C:\ProgressWrk\OspreyVer117102\OspreyFramework\Osprey\CustomClasses\SmartComponents\OspreyViewerControl.r)
    DisplayError Consultingwerk.SmartComponents.Base.SmartViewerControl at line 5281  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Base\SmartViewerControl.r)
    DisplayError Osprey.CustomClasses.SmartComponents.OspreyViewerControl at line 69  (C:\ProgressWrk\OspreyVer117102\OspreyFramework\Osprey\CustomClasses\SmartComponents\OspreyViewerControl.r)
    DeleteRecord Consultingwerk.SmartComponents.Base.SmartViewerControl at line 2306  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Base\SmartViewerControl.r)
    HandleToolClick Consultingwerk.SmartComponents.Implementation.SmartToolbarStateController at line 1008  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Implementation\SmartToolbarStateController.r)
    OnToolClick Consultingwerk.SmartComponents.Implementation.SmartToolbarController at line 2017  (C:\ProgressWrk\OspreyVer117102\SmartComponentLibrary\Consultingwerk\SmartComponents\Implementation\SmartToolbarController.r)
    OnToolClick Osprey.CustomClasses.SmartComponents.OspreyToolbarController at line 496  (C:\ProgressWrk\OspreyVer117102\OspreyFramework\Osprey\CustomClasses\SmartComponents\OspreyToolbarController.r)
    SetupApp.p at line 211  (C:\ProgressWrk\OspreyVer117102\OspreyHost\client\host\SetupApp.r)
    C:\ProgressWrk\OspreyVer117102\OspreyHost\client\host\OspreyHost.p at line 531  (C:\ProgressWrk\OspreyVer117102\OspreyHost\client\host\OspreyHost.r)
    adecomm/_runcode.p at line 678  (adecomm/_runcode.r)
    C:\Progress\OpenEdge\oeide\eclipse\plugins\com.openedge.pdt.debug.core_11.7.5.00\abl\_debuglauncher.p at line 100  (C:\Progress\OpenEdge\oeide\eclipse\plugins\com.openedge.pdt.debug.core_11.7.5.00\abl\_debuglauncher.p)
  7. Mike Fechner
    Mike Fechner avatar
    263 posts
    Registered:
    14 Sep 2016
    01 Jun 2020 in reply to Roger Blanchard
    Link to this post
    And the TableIO target is a Viewer?
  8. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    01 Jun 2020 in reply to Mike Fechner
    Link to this post
    Yes and based on the ActiveTab it changes.

    CASE e:TAB:Key:

                      WHEN "LabelHdr"THEN
                      DO:
                            THIS-OBJECT:LabelHdrToolbar:ActivateSmartNavigationTarget(THIS-OBJECT:LabelHdrAdapter).
                            THIS-OBJECT:LabelHdrToolbar:ActivateSmartTableIOTarget(THIS-OBJECT:LabelHdrViewer). 

                            THIS-OBJECT:LabelHdrAdapter:SmartDataSourceActive            = TRUE.
                            THIS-OBJECT:LabelItemAdapter:SmartDataSourceActive            = FALSE.

                      END.

                      WHEN "LabelItem"THEN
                      DO:
                            THIS-OBJECT:LabelHdrToolbar:ActivateSmartNavigationTarget(THIS-OBJECT:LabelItemAdapter).
                            THIS-OBJECT:LabelHdrToolbar:ActivateSmartTableIOTarget(THIS-OBJECT:LabelItemViewer).

                            THIS-OBJECT:LabelHdrAdapter:SmartDataSourceActive            = FALSE.
                            THIS-OBJECT:LabelItemAdapter:SmartDataSourceActive            = TRUE.

                      END. 

                END CASE.
  9. Mike Fechner
    Mike Fechner avatar
    263 posts
    Registered:
    14 Sep 2016
    02 Jun 2020 in reply to Roger Blanchard
    Link to this post
    In this case the error will be thrown to the Viewer.

    You can override the Viewer's DisplayError (e, plEnsureVisible) method and just do nothing on the CancelException.
  10. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    02 Jun 2020 in reply to Mike Fechner
    Link to this post
    Thanks Mike. I will give that a try.
  11. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    02 Jun 2020 in reply to Mike Fechner
    Link to this post
    That seems to work...thanks.

    METHOD OVERRIDE PROTECTED VOID DisplayError( INPUT e AS Progress.Lang.Error, INPUT plEnsureVisible AS LOGICAL ):
      
      IF TYPE-OF(e, CancelException) THEN
       RETURN.
       
      
      SUPER:DisplayError(INPUT e, INPUT plEnsureVisible).
     END METHOD.
11 posts, 1 answered