3 Replies Latest reply on Mar 21, 2017 9:36 AM by m_yasirali

    Row Selector

    1473309

      Hi,

       

      In one of the editable interactive grid based on the selected rows I need to perform DML operations.

       

      When i used the syntax as

       

      BEGIN

      if :APEX$ROW_SELECTOR = 'X' then

      ------------

      -------------

      END IF;

      END;

       

      There is no effect on the above code, please suggest

       

      Thanks

        • 2. Re: Row Selector
          John Snyders-Oracle

          This feature (sending selected records to the server) is not yet implemented

          See

          Processing selected rows ( not changed / inserted /deleted) in interactive Grid.

          Regards,

          -John

          • 3. Re: Row Selector
            m_yasirali

            FOR PL/SQL Based Approach with submit:

            Settings for your Region:

            Source > SQL Query

            select empno, ename, deptno 

              from emp 

            Attributes > Edit > Enabled = Yes

             

            Settings for your Save Interactive Grid Data process:

            Settings > Set Target Type = PL/SQL Code

            Settings > PL/SQL Code to Insert/Update/Delete

             

            begin 

                 case :APEX$ROW_STATUS 

                 when 'I' then -- Note: In EA2 this has been changed from I to C for consistency with Tabular Forms 

                     insert into emp ( empno, ename, deptno ) 

                     values ( :EMPNO, :ENAME, :DEPTNO ) 

                     returning rowid into :ROWID; 

                 when 'U' then 

                     update emp 

                        set ename  = :ENAME, 

                            deptno = :DEPTNO 

                      where rowid  = :ROWID; 

                 when 'D' then 

                     delete emp 

                     where rowid = :ROWID; 

                 end case; 

            end; 

            If your INSERT statement or your PL/SQL API call generates a primary key as it's the case with the ROWID, you have to assign the result to the primary key column again. In the above case I'm using a RETURNING clause to do so. This is important, because that primary key value is used to query the newly inserted data. Only in the case if the end user enters a primary key value then this is not necessary.

             

             

            FOR Javascript & PL/SQL based Approach without submit

             

            1st get Selected Rows & Store them in a Page Item

            2nd Process Rows on Submit

             

            var gridView = apex.region("mystaticid").widget().interactiveGrid("getViews").grid;

            var records = gridView.getSelectedRecords();

            var ids = records.map(function(r) { return gridView.model.getRecordId(r); } );

            console.log("keys: " + JSON.stringify(ids)

            $s("P1_SELECTED_IDS", ids.join(":"));

             

            the grid widget has option persistSelection even though IG doesn't yet support Submit Includes Selected Rows. So you can set it with Advanced JavaScript Code:

            function(config) {

                config.defaultGridViewOptions = {

                    persistSelection: true

                };

                return config;

            }

             

            if pagination type is Page. The selection is remembered as you navigate next/previous.

            And you can now get the selection from the model. The code looks very similar. Can you spot the difference

             

            var gridView = apex.region("mystaticid").widget().interactiveGrid("getViews").grid;

            var records = gridView.model.getSelectedRecords();

            var ids = records.map(function(r) { return gridView.model.getRecordId(r); } );

            console.log("ids: ", ids.join(":"));

            $s("P1_SELECTED_IDS", ids.join(":"));

             

            Because the grid/model isn't being submitted, I cannot use the APEX$ROW_STATUS to manually delete records either

             

            In the submit process/Dynamic Action you need:

             

            declare

                 l_arr      APEX_APPLICATION_GLOBAL.VC_ARR2;

            BEGIN

                 l_arr := APEX_UTIL.STRING_TO_TABLE('P1_SELECTED_IDS', ':');

             

            for i in 1 .. l_arr.count

              loop

                 delete from MyTable where ROWID = l_arr(i);

              end loop;