7 Replies Latest reply on Nov 9, 2019 10:59 AM by Eslam_Elbyaly

    Selected value on a Grid

    Javier Porrata

      Hi,

       

      Using Apex 19.2

       

      What is the selected value when a row in a grid is selected with the APEX$ROW_SELECTOR

       

      Capture.JPG

      I assume that the CHKBX column is the selector since APEX$ROW_SELECTOR was said to be invalid

       

      Thanks,

      Javier

        • 1. Re: Selected value on a Grid
          Eslam_Elbyaly

          If you need to do an action for selected rows you can get them through the getSelectedRecords api.

          • 2. Re: Selected value on a Grid
            Javier Porrata

            Thanks Eslam for your reply.

             

            What I need is to be able to disable rows based on if is selected or not.  

            I want all rows disable so the user can't click on any column unless the row is selected.

            • 3. Re: Selected value on a Grid
              Eslam_Elbyaly

              How would you plan to prevent user from editing a record when he is the one to disable/enable it?!

              Tell me what exactly you're trying to do(The real world situation). 

              • 4. Re: Selected value on a Grid
                Natalie G

                Javier Porrata wrote:

                 

                I want all rows disable so the user can't click on any column unless the row is selected.

                I don't think you can do that from within the framework. Apex mediates all DA events, and I don't find any Apex equivalent to `preventDefault` or `stopPropagation`. You'll have to add your own DOM event handler. Define a DOM `clilck` handler to the Page `Function and Global Variable Declaration`

                var selectedOnly = false;
                
                function clickCatcher (browserEvent) {
                    if (!window.selectedOnly) return;
                
                    var tr = browserEvent.target.closest('tr');
                    if (tr && !tr.classList.contains('is-selected')) {
                      browserEvent.stopPropagation();
                    }
                };
                

                attach an event listener in `Execute when Page Loads`

                document.getElementById('my_ig')
                        .addEventListener('click', clickCatcher, true);
                //document.getElementById('my_ig').removeEventListener('click', clickCatcher, true);
                

                and set `window.selectedOnly` to true when you want to block clicks on rows that are not selected.

                 

                Now some bad news: (1) In 19.1 you'll still lose the selection when you cllck on a selected row. (2) You can still navigate to an unselected row using the keyboard. (We're only blocking clicks here.)

                1 person found this helpful
                • 5. Re: Selected value on a Grid
                  Javier Porrata

                  Hi Eslam,

                   

                  What I would like to be able to do is having a bunch of unpaid invoices be able to apply payments to more than one invoice with one check.

                   

                  I need to select the invoices I want to pay and from a button be able to go through the selected invoices.

                   

                  The problem is that when selecting the invoices if the user clicks a column other than the checkbox all the selected invoices get unselected. That is what I want to avoid.

                   

                  Thanks Eslam

                  • 6. Re: Selected value on a Grid
                    Javier Porrata

                    Thanks Natalie for your help!!

                    • 7. Re: Selected value on a Grid
                      Eslam_Elbyaly

                      You can disable all columns through a "Selection Change" dynamic action. And that's after checking that there are more than one row checked using getSelectedRecords() api and "length" array property.

                      1 person found this helpful