Forum Stats

  • 3,768,656 Users
  • 2,252,827 Discussions
  • 7,874,672 Comments

Discussions

IG 5.1 and 18.1, model.setValue + ig-scroll creates duplicate rows

Abhi_Pandey
Abhi_Pandey Member Posts: 5 Red Ribbon
edited Jan 10, 2019 3:14AM in APEX Discussions

Hi,

I am using Apex 18.1 and facing below problem in IG..

Whenever I do model.setValue for a particular record for a column in IG and then scroll IG to get fresh rows added to model the initial set of 40 odd records gets duplicated.

I have created a sample page here https://apex.oracle.com/pls/apex/f?p=11549:21 to replicate.

Click on "Click to setValue" button followed by long scroll of IG to replicate.

Could someone pls tell what is causing such behavior. Same issue exists in 5.1 as well.

My requirement is to update value in model for a hidden indicator column when a particular cell is clicked. I am able to do it but as soon as setValue is used the duplicate issue comes up after scroll.

Thanks in advance.

Abhi

Answers

  • Pierre Yotti
    Pierre Yotti Member Posts: 4,040 Bronze Crown
    edited Oct 31, 2018 8:22AM

    Hi,

    i don't have that issue. But instead of setValue in a model like you made, i suggest you to use the Row Action Menu Widget for the IG. It is in term of usability better than use one button. The user know that he should set the Value for the Current row. That is what i means

    Bildschirmfoto 2018-10-31 um 13.19.29.png

    I added a custom action menu to set the Value.

    Just create a DA on page load and use that code

    var value;

    var record;

    var view = apex.region("new_ig").widget().interactiveGrid("getViews", "grid");

    var menu$ = view.rowActionMenu$;

    menu$.menu("option").items.push({

        type: "action",

        label: "click to set Value",

        icon: "fa fa-home",

        id: "setv",

        action: function(menu, element) {

            record = view.getContextRecord(element)[0];

            view.model.setValue(record, "IND", 'Y');

        }

    });

    Demo

    https://apex.oracle.com/pls/apex/f?p=23342:42

  • Abhi_Pandey
    Abhi_Pandey Member Posts: 5 Red Ribbon
    edited Oct 31, 2018 10:27AM

    Hi Alli,

    Thanks for your reply. I agree, the button I am using is just to create a quick replication of issue If you were able to see the duplication on my page. I have just hardcoded to set first record from model.

    Also saw in your case you just have 16 odd rows if you can have a ig with more than 100 odd rows then you get a scroll after say 40 -50 rows, its then when duplication happens.

    IN real world I am using setValue to change value of a column when user selects the checkbox for that row.

    Amazingly it used to work few months back but suddenly I am able to recreate it everywhere don't know why you are not getting it. First I thought something to do with upgrade to 18.1 but was able to reproduce it in 5.1 as well.

    Thanks,

    Abhi

  • Pierre Yotti
    Pierre Yotti Member Posts: 4,040 Bronze Crown
    edited Oct 31, 2018 11:02AM

    Here is a example with more than100 Rows

    https://apex.oracle.com/pls/apex/f?p=23342:42

    But i don't get that issue

  • Abhi_Pandey
    Abhi_Pandey Member Posts: 5 Red Ribbon
    edited Oct 31, 2018 9:51PM

    Hi Alli,

    Its happening on your page as well just do set value and give it a nice quick scroll. I have added the screen shot of DOM below where you can see how rownum =1 rows get appended again after rownum = 50. Unfortunately both the duplicate rows cant be captured in single screen shot as there is a diff of 50 rows between them.

    pastedImage_1.png

  • Jeremy Webb
    Jeremy Webb Member Posts: 259 Blue Ribbon
    edited Nov 1, 2018 10:48AM

    We have often seen similar types of issues. Seems to be better than it was in 18.1

    One thing that makes a big difference, for the IG, what is your primary key. Ensuring this really is a unique value sorted this problem a few times.

    Sometimes it is affected by how you refresh the grid. We found sometimes a full region refresh was required rather than just refreshing the specific row that had been updated, but generally this has been resolved in 18.1.

    Regards,

    Jeremy

  • John Snyders-Oracle
    John Snyders-Oracle Member Posts: 1,408 Employee
    edited Nov 1, 2018 11:33AM

    Hi Abhi,

    This sounds like it could be bug 28834484. Does this only happen when pagination type is scroll? What about headings stuck to page or region, does that have any effect?

    Regards,
    -John

    Abhi_Pandey
  • Abhi_Pandey
    Abhi_Pandey Member Posts: 5 Red Ribbon
    edited Nov 1, 2018 11:56PM

    Hi John,

    Thanks for acknowledging the query. Yeah, it looks like the bug you quoted above.

    I just tried on various combinations as below, seems it has no effect on issue. Only thing that triggers it, seems to be "gridpagechange" event of IG.

    Every time user scrolls/paginates past 50 rows it appends first set of 50 rows immediately after 50th row.

    Also it occurs even with dynamic action 'Set Value' for column as well, as i assume internally that dynamic action also calls model.setValue.

    pastedImage_1.png

    gridpagechange

    Regards,

    Abhi

  • Abhi_Pandey
    Abhi_Pandey Member Posts: 5 Red Ribbon
    edited Jan 10, 2019 3:14AM

    Hi John,

    We checked on Oracle support and there is no information on when this fix (for bug 28834484) will be available.

    Do you have any Idea?

    Thanks,

    Abhi

  • Umesh_C
    Umesh_C Member Posts: 2 Green Ribbon
    edited Apr 21, 2021 5:15AM

    Hi Abhi,

    The default functionality of IG is that, it will always select the first loaded set of records mostly 50 records. To work around we need to load all records in IG model and then perform any assignment on columns.

    Check the below code, This will help to remove duplicate records in grid and update issue with more that 50 records.


    apex.region("IG_ORG_DATA").widget().interactiveGrid("getActions").set("edit", true);

    var widget = apex.region('IG_ORG_DATA').widget();

    var grid = widget.interactiveGrid('getViews','grid');

    var model = grid.model;

    var lSpinner$;


    lSpinner$ = apex.util.showSpinner($( "#IG_ORG_DATA" ));

    model.fetchAll( function( status ) {

      if ( status.done ) {

        model.forEach( function( record, index, id ) {

          // do something with each record

          model.setValue(record,"EDIT_FLAG",'Y'); 

          }

        )

      lSpinner$.remove();

      } 

    });


    Thanks,

    Umesh