5 Replies Latest reply on Jan 17, 2019 7:35 PM by Jorgelina

    APEX 5.1.3.00.05 Interactive Grid show duplicate rows

    FabianodeSouza

      I'm suffering here. This error always occurs when I REMOVE* a filter and ADD** a new one.

      * to remove a filter I'm using this:

      apex.region("MY_GRID_ID").widget().interactiveGrid("deleteFilter",columns[i].id);

      ** to add a new filter I'm using this:

      objFilters.interactiveGrid("addFilter", {

                  type: 'column',

                  columnType: 'column',

                  columnName: pColName,

                  operator: pOperator,

                  value: v,

                  save: false,

                  isCaseSensitive: false

              });

       

              But when  I click in Refresh(image below), the Grid is re-drawn and show the correct rows:

        • 1. Re: APEX 5.1.3.00.05 Interactive Grid show duplicate rows
          Mahmoud_Rabie

          Hi Fabianode,

           

          Could you reproduce it on apex.oracle.com to help you there.

           

          Please provide workspace and a developer account.

           

          Regards

          Mahmoud

          • 2. Re: APEX 5.1.3.00.05 Interactive Grid show duplicate rows
            FabianodeSouza

            Hi Mahmoud,

             

            The problem is my old version APEX 5.1.3 and in the apex.oracle.com they are using the new version 18.2.

            But maybe you can help me with my javascript functions

            var arrayFilterNames = [];
            var browserName = navigator.userAgent;
            
            
            /** Filter parameters
            * pColName : Table COLUMN 
            * pItemName : Can be any item that is used to filter, like : P47_PROTEIN_FILTER
            * pToleranceItemName : number between 0-50 that will influence directly with the filters(pItemName) : P47_PROTEIN_TOLERANCE
            *   Exp.: P47_PROTEIN_FILTER := 1500 and P47_PROTEIN_TOLERANCE := 10  => FILTER = BETWEEN 1490 AND 1510
            *  pOperator : BETWEEN/GTE/EQ
            *  pValue : 0 or 1 - UNUSED
            **/
            function addFilter(pColName, pItemName, pToleranceItemName, pOperator,pValue) {
                
                var objFilters = apex.region("RGN_IG_DIETS").widget();
            
            
                
                if (pOperator === 'BETWEEN'){
                    v = parseFloat($v(pItemName));
                    t = parseFloat($v(pToleranceItemName));
                    v1 = Math.floor(v*(1-t));
                    v2 = Math.ceil(v*(1+t));
                    v = v1 + '~' + v2;
            
            
                }else{
                    
                    v = Math.floor(parseFloat(pValue));
              
                }
            
            
                var i;
            
                // first, check if this filter isn't already present, and UPDATE if it is
                var filters = objFilters.interactiveGrid("getFilters");
                if (filters.length == 0) {
                    arrayFilterNames = [];
                };
                var filterPresent = false;
                i=0; 
                
                if (arrayFilterNames.length > 0) {
                    for (i = 0; i < arrayFilterNames.length; i++) {
                      
                        if ( pColName == arrayFilterNames[i]) {
                            
                            objFilters.interactiveGrid("updateFilter",
                                filters[i].id,
                                {   type: 'column',
                                    columnType: 'column',
                                    columnName: pColName,
                                    operator: pOperator,
                                    value: v,
                                    save: false,
                                    isCaseSensitive: false
                                });
                            filterPresent = true;
                        } 
                    } 
                }; 
                 i=0;
            
                
                // next, INSERT a new filter it not already present
                if (filterPresent == false) {
                    objFilters.interactiveGrid("addFilter", {
                        type: 'column',
                        columnType: 'column',
                        columnName: pColName,
                        operator: pOperator,
                        value: v,
                        save: false,
                        isCaseSensitive: false
                    });
                    
            
            
                    arrayFilterNames.push(pColName);
                   
                }; // if not filterPresent
            
            
            
            
                //reset  paramenters 
                t = null;
                v1 = null;
                v2 = null;
                pColName = null;
                pOperator = null;
                
            };
            
            
            
            
            
            
            function removeFilter(pColName){
            
            
                 var objFilters = apex.region("RGN_IG_DIETS").widget();
                
                //takes the name of the COLUMN that has been filtered and removes it from the filter list of the grid
               
                if(pColName.indexOf('ENERGY') > 0){
                    pColName = 'TOTALENERGY';
                }else if(pColName.indexOf('INCLUDE') > 0){
                    pColName = 'INCLUDEITEMS';
                }else if(pColName.indexOf('EXCLUDE') > 0){
                    pColName = 'EXCLUDEITEMS';
                }else{
                    pColName = 'PERCENT' + pColName.replace("P47_", "").replace("_FILTER", "").replace("_TOLERANCE", "").replace("_STATE", "");
                }
            
            
            
                var columns = objFilters.interactiveGrid("getFilters");
                if (columns.length == 0) {
                    arrayFilterNames = [];
                };
                
                if (arrayFilterNames.length > 0) {
                    for (var i = 0; i < arrayFilterNames.length; i++) {
            
            
                        if ( pColName == arrayFilterNames[i]) {
                            
                            objFilters.interactiveGrid("deleteFilter",columns[i].id);
                            arrayFilterNames.splice(i,1);
                        }
                    }
                    
                }
                 
            }
            
            
            
            
            function removeAllFilters(pRefresh = true){
            
            
                var objFilters = apex.region("RGN_IG_DIETS").widget(),
                    columns = objFilters.interactiveGrid("getFilters");
                
                if(columns.length > 0){
            
            
                    for (i = 0; i < columns.length; i++) {
            
            
                        apex.region("RGN_IG_DIETS").widget().interactiveGrid("deleteFilter",columns[i].id);
            
            
                    }
            
            
                    arrayFilterNames = [];
                    
                }
            }
            
            • 3. Re: APEX 5.1.3.00.05 Interactive Grid show duplicate rows
              Jorgelina

              Hi,

               

              I don't have experience with this specifically, but I have coded lots of things in jscript to interact with IG and have a lot more control on what happens, so I know that 5.1 &interactive grid is quite an issue when you need to do things through jscript, and I think that what is missing is what you mentioned before, and that is adding a refresh line for your region, so you can get the data as you need it to be.

              When working with jscript directly on the IG many times you need to "force" your IG to act upon of what happened with jscript since won't do it automatically as when you actually add a filter through the toolbars.

              Regards.

              • 4. Re: APEX 5.1.3.00.05 Interactive Grid show duplicate rows
                FabianodeSouza

                Jorge,

                 

                Me parece que fala portugues ou español. Um prazer em conhece-lo.

                Deixa eu ver se entendi bem, vc sugere eu colocar um : apex.region("RGN_IG_DIETS").refresh(); após uma ação de remover ou adicionar filtro. É isso?

                Pois eu cheguei a fazer isso, mas depois de varias atualizações o resultado é igual. pode ser que eu não achei o local certo para colocar essa linha.

                • 5. Re: APEX 5.1.3.00.05 Interactive Grid show duplicate rows
                  Jorgelina

                  Sorry,

                   

                  I do not speak portuguese, but I do speak spanish.

                  My name IS Jorgelina, and not Jorge... and if I am getting it right (which, again, is hard for me since I do not speak portuguese) what you are saying, yes, you should add the  apex.region("RGN_IG_DIETS").refresh();   AFTER you toyed with the filters, that is after you removed and added your filters.

                  Regards.