Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    12.0 sorting records

    Hi Isomorphic,

    I have a new problem that only occurs in 12.0. version (12.0p/v12.0p_2018-08-23), not in 6.1.
    Click image for larger version  Name:	12_0_chat_topics.gif Views:	1 Size:	98.9 KB ID:	254828


    I think this may be related to https://forums.smartclient.com/forum...-11-1-and-12-0. You can see there my createRecordComponents code.
    Records are sorted by field "T_CHAT__LAST_ENTRY", when that value changes, the records should be sorted again.

    I made a test case that does not show my problem directly, but I think it is related to my problem so let's start with it.
    When I change the value of any record, that's always affect the first record and change it.
    Click image for larger version  Name:	12_0_chat_topics_test_case.gif Views:	1 Size:	91.7 KB ID:	254829

    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.SortSpecifier;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.SelectionStyle;
    import com.smartgwt.client.types.SortDirection;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Label;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS extends VLayout implements EntryPoint {
        private IButton recreateBtn;
        private final String fakeLGFName = "fakeLGFName";
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            setWidth100();
            setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    new MyWindow().show();
                }
            });
            addMember(recreateBtn);
            new MyWindow().show();
            draw();
        }
    
        private class MyWindow extends Window {
            public MyWindow() {
                setWidth(400);
                setHeight(600);
                setMembersMargin(0);
                setModalMaskOpacity(70);
                setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                SC.logWarn(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                setShowMinimizeButton(false);
                setIsModal(true);
                setShowModalMask(true);
                centerInPage();
    
                VLayout vL = new VLayout();
    
                // Img svgImg = new Img("http://127.0.0.1:8888/builtinds/tools/images/kiwi.svg", 100, 100);
                ListGrid lg = new ListGrid() {
                    {
                        setSelectionType(SelectionStyle.SINGLE);
                        setVirtualScrolling(true);
                        setShowRecordComponents(true);
                        setShowRecordComponentsByCell(true);
                        // Records becomes unreadable every next click in 12.0. version, we don't expect many record so this is fine solution.
                        // setRecordComponentPoolingMode(RecordComponentPoolingMode.RECYCLE);
                        setPoolComponentsPerColumn(true);
                        setFixedRecordHeights(true);
                        setRecordComponentHeight(56);
                        setCanSort(false);
                        setCanPickFields(false);
                        setCanResizeFields(false);
                        setCanAutoFitFields(false);
                        setCanGroupBy(false);
    
                        setAutoFetchData(false);
                        setDataSource("animals");
    
                        ListGridField scientificNameLGF = new ListGridField(fakeLGFName);
                        ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
                        lifeSpanLGF.setCanEdit(true);
    
                        setFields(scientificNameLGF, lifeSpanLGF);
    
                        setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                        fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Endangered")));
                    }
    
                    @Override
                    protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
                        String fieldName = this.getFieldName(colNum);
                        if (fakeLGFName.equals(fieldName)) {
                            String topicName = record.getAttributeAsString("scientificName");
    
                            Label testLabel = new Label();
                            testLabel.setContents(topicName);
    
                            VLayout vLayout = new VLayout(6);
                            vLayout.setHeight(50);
                            vLayout.setWidth100();
                            vLayout.setMembers(testLabel);
    
                            this.setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                            return vLayout;
                        } else
                            return null;
                    }
                };
    
                vL.addMembers(lg);
    
                addItem(vL);
            }
        }
    }

    Best regards
    Pavo
    Last edited by pavo123; 3 Sep 2018, 06:41.

    #2
    In my test case, calling "setSort" in createRecordComponent is probably incorrect, so better solution:

    Code:
                        addDataChangedHandler(new DataChangedHandler() {
                            @Override
                            public void onDataChanged(DataChangedEvent event) {
                                setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                            }
                        });
    But the effect is the same.

    Comment


      #3
      The setSort() call within createRecordComponent() is completely invalid.

      Elsewhere you have posted that code in your #2 post here just crashes. So which is it, same result, or it crashes?

      Note also: it doesn't make any sense to setSort() on dataChanged(), as that would just perform a sort when one is potentially already being performed. What is this code meant to do?

      Comment


        #4
        Hi Isomorphic,

        my mistake, I should have been a bit more precise and correct.
        This test case shows exactly what is happening in my app.

        Click image for larger version

Name:	12_0_chatter.gif
Views:	127
Size:	119.0 KB
ID:	254873
        Code:
        package com.smartgwt.sample.client;
        
        import com.google.gwt.core.client.EntryPoint;
        import com.smartgwt.client.Version;
        import com.smartgwt.client.core.KeyIdentifier;
        import com.smartgwt.client.data.AdvancedCriteria;
        import com.smartgwt.client.data.Criterion;
        import com.smartgwt.client.data.SortSpecifier;
        import com.smartgwt.client.types.OperatorId;
        import com.smartgwt.client.types.SelectionStyle;
        import com.smartgwt.client.types.SortDirection;
        import com.smartgwt.client.util.Page;
        import com.smartgwt.client.util.PageKeyHandler;
        import com.smartgwt.client.util.SC;
        import com.smartgwt.client.widgets.Canvas;
        import com.smartgwt.client.widgets.IButton;
        import com.smartgwt.client.widgets.Label;
        import com.smartgwt.client.widgets.Window;
        import com.smartgwt.client.widgets.events.ClickEvent;
        import com.smartgwt.client.widgets.events.ClickHandler;
        import com.smartgwt.client.widgets.grid.ListGrid;
        import com.smartgwt.client.widgets.grid.ListGridField;
        import com.smartgwt.client.widgets.grid.ListGridRecord;
        import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
        import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
        import com.smartgwt.client.widgets.layout.HLayout;
        import com.smartgwt.client.widgets.layout.VLayout;
        
        public class BuiltInDS extends VLayout implements EntryPoint {
            private IButton recreateBtn;
            private final String fakeLGFName = "fakeLGFName";
            private ListGrid mainLG;
            private ListGrid secondLG;
        
            public ListGrid getSecondLG() {
                return secondLG;
            }
        
            public void onModuleLoad() {
                KeyIdentifier debugKey = new KeyIdentifier();
                debugKey.setCtrlKey(true);
                debugKey.setKeyName("D");
        
                Page.registerKey(debugKey, new PageKeyHandler() {
                    public void execute(String keyName) {
                        SC.showConsole();
                    }
                });
        
                setWidth100();
                setHeight100();
        
                recreateBtn = new IButton("Recreate");
                recreateBtn.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        new MyWindow().show();
                    }
                });
                addMember(recreateBtn);
                new MyWindow().show();
                draw();
            }
        
            private class MyWindow extends Window {
                public MyWindow() {
                    setWidth(800);
                    setHeight(600);
                    setMembersMargin(0);
                    setModalMaskOpacity(70);
                    setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                    SC.logWarn(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                    setShowMinimizeButton(false);
                    setIsModal(true);
                    setShowModalMask(true);
                    centerInPage();
        
                    HLayout hL = new HLayout();
        
                    mainLG = new MainLG();
        
                    secondLG = new SecondLG();
        
                    VLayout vL1 = new VLayout();
                    vL1.setMembers(mainLG);
        
                    VLayout vL2 = new VLayout();
                    vL2.setMembers(secondLG);
        
                    hL.setMembers(vL1, vL2);
                    addItem(hL);
                }
        
                private class MainLG extends ListGrid {
                    public MainLG() {
        
                        addRecordClickHandler(new RecordClickHandler() {
                            @Override
                            public void onRecordClick(RecordClickEvent event) {
                                getSecondLG().setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                                getSecondLG().fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Endangered")));
                            }
                        });
                        setSelectionType(SelectionStyle.SINGLE);
                        setVirtualScrolling(true);
                        setShowRecordComponents(true);
                        setShowRecordComponentsByCell(true);
                        setPoolComponentsPerColumn(true);
                        setFixedRecordHeights(true);
                        setRecordComponentHeight(56);
                        setCanSort(false);
                        setCanPickFields(false);
                        setCanResizeFields(false);
                        setCanAutoFitFields(false);
                        setCanGroupBy(false);
                        setHeight100();
        
                        setAutoFetchData(false);
                        setDataSource("animals");
        
                        ListGridField scientificNameLGF = new ListGridField(fakeLGFName);
                        ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
                        lifeSpanLGF.setCanEdit(true);
        
                        setFields(scientificNameLGF, lifeSpanLGF);
        
                        setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                        fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Endangered")));
                    }
        
                    @Override
                    protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
                        String fieldName = this.getFieldName(colNum);
                        if (fakeLGFName.equals(fieldName)) {
                            String topicName = record.getAttributeAsString("scientificName");
        
                            Label testLabel = new Label();
                            testLabel.setContents(topicName);
        
                            VLayout vLayout = new VLayout(6);
                            vLayout.setHeight(50);
                            vLayout.setWidth100();
                            vLayout.setMembers(testLabel);
        
                            return vLayout;
                        } else
                            return null;
                    }
                }
        
                private class SecondLG extends ListGrid {
                    public SecondLG() {
                        setSelectionType(SelectionStyle.SINGLE);
                        setVirtualScrolling(true);
                        setShowRecordComponents(true);
                        setShowRecordComponentsByCell(true);
                        setPoolComponentsPerColumn(true);
                        setFixedRecordHeights(true);
                        setRecordComponentHeight(56);
                        setCanSort(false);
                        setCanPickFields(false);
                        setCanResizeFields(false);
                        setCanAutoFitFields(false);
                        setCanGroupBy(false);
                        setHeight100();
        
                        setAutoFetchData(false);
                        setDataSource("animals");
        
                        ListGridField scientificNameLGF = new ListGridField(fakeLGFName);
                        ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
                        lifeSpanLGF.setCanEdit(true);
        
                        setFields(scientificNameLGF, lifeSpanLGF);
        
                        setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                        // fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Threatened")));
                    }
        
                    @Override
                    protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
                        String fieldName = this.getFieldName(colNum);
                        if (fakeLGFName.equals(fieldName)) {
                            String topicName = record.getAttributeAsString("scientificName");
        
                            Label testLabel = new Label();
                            testLabel.setContents(topicName);
        
                            VLayout vLayout = new VLayout(6);
                            vLayout.setHeight(50);
                            vLayout.setWidth100();
                            vLayout.setMembers(testLabel);
        
                            return vLayout;
                        } else
                            return null;
                    }
                }
            }
        }
        As I've already said, in the last version everything was working fine.

        Best regards
        Pavo

        Comment


          #5
          Your record components are just exactly the same text as the actual column data, so they basically float over the column data and are invisible. Then, when record order is shuffled due to a change, since you have no updateRecordComponent() implementation, you end up with a recordComponent that was created for another record floating over a different record, so you get two lines of text on top of each other, looking scrambled.

          This might have been "working fine" in a previous version where the pattern of updateRecordComponents() calls happens to differ, but it's still an application bug that would show up in other circumstances.

          Comment


            #6
            Hi Isomorphic,

            I expected that my app would have a greater number of functionalities in 12.0., or at least the same number.
            If you say it's bug in app, okay, but please take a look at this.

            Using (6.1p/v11.1p_2018-08-29), working fine:
            Click image for larger version  Name:	12_0_chatter_6_1.gif Views:	1 Size:	171.9 KB ID:	254902

            Using (12.0p/v12.0p_2018-08-23), please take a look closely this one.
            I changed value of the first record, the records are mixed,
            I changed value of the second record, nothing changes,
            I didn't changed value of the third record, nothing changes,
            I changed value of the fourth record, all records are not mixed any more? But still not sorted correctly.
            Click image for larger version  Name:	12_0_chatter_12_0.gif Views:	1 Size:	142.7 KB ID:	254903

            And my code is without "updateRecordComponent"
            But if I need to use "updateRecordComponent", I can use something like
            Code:
                        @Override
                        public Canvas updateRecordComponent(ListGridRecord record, Integer colNum, Canvas component, boolean recordChanged) {
                            if (recordChanged)
                                return null; //return "updated component"
                            else
                                return component;
                        }
            but it won't help to solve this problem. Maybe you have a better idea?

            In my application, two ListGrids are connected, the left shows chat topics, the right shows chat messages.
            When a user sends a message, that topic should be in the first place (sorted by "last entry").
            But that is the same behavior as this test case shows. The code is the same for both "gifs" above.

            Code:
            package com.smartgwt.sample.client;
            
            import com.google.gwt.core.client.EntryPoint;
            import com.smartgwt.client.Version;
            import com.smartgwt.client.core.KeyIdentifier;
            import com.smartgwt.client.data.AdvancedCriteria;
            import com.smartgwt.client.data.Criterion;
            import com.smartgwt.client.data.SortSpecifier;
            import com.smartgwt.client.types.OperatorId;
            import com.smartgwt.client.types.SelectionStyle;
            import com.smartgwt.client.types.SortDirection;
            import com.smartgwt.client.util.Page;
            import com.smartgwt.client.util.PageKeyHandler;
            import com.smartgwt.client.util.SC;
            import com.smartgwt.client.widgets.Canvas;
            import com.smartgwt.client.widgets.IButton;
            import com.smartgwt.client.widgets.Label;
            import com.smartgwt.client.widgets.Window;
            import com.smartgwt.client.widgets.events.ClickEvent;
            import com.smartgwt.client.widgets.events.ClickHandler;
            import com.smartgwt.client.widgets.grid.ListGrid;
            import com.smartgwt.client.widgets.grid.ListGridField;
            import com.smartgwt.client.widgets.grid.ListGridRecord;
            import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
            import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
            import com.smartgwt.client.widgets.layout.HLayout;
            import com.smartgwt.client.widgets.layout.VLayout;
            
            public class BuiltInDS extends VLayout implements EntryPoint {
                private IButton recreateBtn;
                private final String fakeLGFName = "fakeLGFName";
                private ListGrid mainLG;
                private ListGrid secondLG;
            
                public ListGrid getSecondLG() {
                    return secondLG;
                }
            
                public void onModuleLoad() {
                    KeyIdentifier debugKey = new KeyIdentifier();
                    debugKey.setCtrlKey(true);
                    debugKey.setKeyName("D");
            
                    Page.registerKey(debugKey, new PageKeyHandler() {
                        public void execute(String keyName) {
                            SC.showConsole();
                        }
                    });
            
                    setWidth100();
                    setHeight100();
            
                    recreateBtn = new IButton("Recreate");
                    recreateBtn.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            new MyWindow().show();
                        }
                    });
                    addMember(recreateBtn);
                    new MyWindow().show();
                    draw();
                }
            
                private class MyWindow extends Window {
                    public MyWindow() {
                        setWidth(800);
                        setHeight(600);
                        setMembersMargin(0);
                        setModalMaskOpacity(70);
                        setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                        SC.logWarn(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                        setShowMinimizeButton(false);
                        setIsModal(true);
                        setShowModalMask(true);
                        centerInPage();
            
                        HLayout hL = new HLayout();
            
                        mainLG = new MainLG();
            
                        secondLG = new SecondLG();
            
                        VLayout vL1 = new VLayout();
                        vL1.setMembers(mainLG);
            
                        VLayout vL2 = new VLayout();
                        vL2.setMembers(secondLG);
            
                        hL.setMembers(vL1, vL2);
                        addItem(hL);
                    }
            
                    private class MainLG extends ListGrid {
                        public MainLG() {
            
                            addRecordClickHandler(new RecordClickHandler() {
                                @Override
                                public void onRecordClick(RecordClickEvent event) {
                                    getSecondLG().setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                                    getSecondLG().fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Endangered")));
                                }
                            });
                            setSelectionType(SelectionStyle.SINGLE);
                            setVirtualScrolling(true);
                            setShowRecordComponents(true);
                            setShowRecordComponentsByCell(true);
                            setPoolComponentsPerColumn(true);
                            setFixedRecordHeights(true);
                            setRecordComponentHeight(56);
                            setCanSort(false);
                            setCanPickFields(false);
                            setCanResizeFields(false);
                            setCanAutoFitFields(false);
                            setCanGroupBy(false);
                            setHeight100();
            
                            setAutoFetchData(false);
                            setDataSource("animals");
            
                            ListGridField scientificNameLGF = new ListGridField(fakeLGFName);
                            ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
                            lifeSpanLGF.setCanEdit(true);
            
                            setFields(scientificNameLGF, lifeSpanLGF);
            
                            setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                            fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Endangered")));
                        }
            
                        @Override
                        protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
                            String fieldName = this.getFieldName(colNum);
                            if (fakeLGFName.equals(fieldName)) {
                                String topicName = record.getAttributeAsString("scientificName");
            
                                Label testLabel = new Label();
                                testLabel.setContents(topicName);
            
                                VLayout vLayout = new VLayout(6);
                                vLayout.setHeight(50);
                                vLayout.setWidth100();
                                vLayout.setMembers(testLabel);
            
                                return vLayout;
                            } else
                                return null;
                        }
                    }
            
                    private class SecondLG extends ListGrid {
                        public SecondLG() {
                            setSelectionType(SelectionStyle.SINGLE);
                            setVirtualScrolling(true);
                            setShowRecordComponents(true);
                            setShowRecordComponentsByCell(true);
                            setPoolComponentsPerColumn(true);
                            setFixedRecordHeights(true);
                            setRecordComponentHeight(56);
                            setCanSort(false);
                            setCanPickFields(false);
                            setCanResizeFields(false);
                            setCanAutoFitFields(false);
                            setCanGroupBy(false);
                            setHeight100();
            
                            setAutoFetchData(false);
                            setDataSource("animals");
            
                            ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
                            lifeSpanLGF.setCanEdit(true);
            
                            setFields(lifeSpanLGF);
            
                            setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                        }
                    }
                }
            }
            Best regards
            Pavo
            Last edited by pavo123; 6 Sep 2018, 02:41.

            Comment


              #7
              I also tried this code, but without success.

              Code:
              package com.smartgwt.sample.client;
              
              import com.google.gwt.core.client.EntryPoint;
              import com.smartgwt.client.Version;
              import com.smartgwt.client.core.KeyIdentifier;
              import com.smartgwt.client.data.AdvancedCriteria;
              import com.smartgwt.client.data.Criterion;
              import com.smartgwt.client.data.SortSpecifier;
              import com.smartgwt.client.types.OperatorId;
              import com.smartgwt.client.types.RecordComponentPoolingMode;
              import com.smartgwt.client.types.SelectionStyle;
              import com.smartgwt.client.types.SortDirection;
              import com.smartgwt.client.util.Page;
              import com.smartgwt.client.util.PageKeyHandler;
              import com.smartgwt.client.util.SC;
              import com.smartgwt.client.widgets.Canvas;
              import com.smartgwt.client.widgets.IButton;
              import com.smartgwt.client.widgets.Label;
              import com.smartgwt.client.widgets.Window;
              import com.smartgwt.client.widgets.events.ClickEvent;
              import com.smartgwt.client.widgets.events.ClickHandler;
              import com.smartgwt.client.widgets.grid.ListGrid;
              import com.smartgwt.client.widgets.grid.ListGridField;
              import com.smartgwt.client.widgets.grid.ListGridRecord;
              import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
              import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
              import com.smartgwt.client.widgets.layout.HLayout;
              import com.smartgwt.client.widgets.layout.VLayout;
              
              public class BuiltInDS extends VLayout implements EntryPoint {
                  private IButton recreateBtn;
                  private final String fakeLGFName = "fakeLGFName";
                  private ListGrid mainLG;
                  private ListGrid secondLG;
              
                  public ListGrid getSecondLG() {
                      return secondLG;
                  }
              
                  public void onModuleLoad() {
                      KeyIdentifier debugKey = new KeyIdentifier();
                      debugKey.setCtrlKey(true);
                      debugKey.setKeyName("D");
              
                      Page.registerKey(debugKey, new PageKeyHandler() {
                          public void execute(String keyName) {
                              SC.showConsole();
                          }
                      });
              
                      setWidth100();
                      setHeight100();
              
                      recreateBtn = new IButton("Recreate");
                      recreateBtn.addClickHandler(new ClickHandler() {
                          @Override
                          public void onClick(ClickEvent event) {
                              new MyWindow().show();
                          }
                      });
                      addMember(recreateBtn);
                      new MyWindow().show();
                      draw();
                  }
              
                  private class MyWindow extends Window {
                      protected ListGridRecord record;
              
                      public MyWindow() {
                          setWidth(800);
                          setHeight(600);
                          setMembersMargin(0);
                          setModalMaskOpacity(70);
                          setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                          SC.logWarn(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
                          setShowMinimizeButton(false);
                          setIsModal(true);
                          setShowModalMask(true);
                          centerInPage();
              
                          HLayout hL = new HLayout();
              
                          mainLG = new MainLG();
              
                          secondLG = new SecondLG();
              
                          VLayout vL1 = new VLayout();
                          vL1.setMembers(mainLG);
              
                          VLayout vL2 = new VLayout();
                          vL2.setMembers(secondLG);
              
                          hL.setMembers(vL1, vL2);
                          addItem(hL);
                      }
              
                      private class MainLG extends ListGrid {
                          public MainLG() {
              
                              addRecordClickHandler(new RecordClickHandler() {
                                  @Override
                                  public void onRecordClick(RecordClickEvent event) {
                                      getSecondLG().setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                                      getSecondLG().fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Endangered")));
                                  }
                              });
                              setSelectionType(SelectionStyle.SINGLE);
                              setVirtualScrolling(true);
                              setShowRecordComponents(true);
                              setShowRecordComponentsByCell(true);
                              setPoolComponentsPerColumn(true);
                              setRecordComponentPoolingMode(RecordComponentPoolingMode.RECYCLE);
                              setFixedRecordHeights(true);
                              setRecordComponentHeight(56);
                              setCanSort(false);
                              setCanPickFields(false);
                              setCanResizeFields(false);
                              setCanAutoFitFields(false);
                              setCanGroupBy(false);
                              setHeight100();
              
                              setAutoFetchData(false);
                              setDataSource("animals");
              
                              ListGridField scientificNameLGF = new ListGridField(fakeLGFName);
                              ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
                              lifeSpanLGF.setCanEdit(true);
              
                              setFields(scientificNameLGF, lifeSpanLGF);
              
                              setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                              fetchData(new AdvancedCriteria(new Criterion("status", OperatorId.EQUALS, "Endangered")));
                          }
              
                          @Override
                          protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
                              return updateRecordComponent(record, colNum, null, true);
                          }
              
                          @Override
                          public Canvas updateRecordComponent(ListGridRecord record, Integer colNum, Canvas component, boolean recordChanged) {
                              String fieldName = this.getFieldName(colNum);
                              if (fieldName.equals(fakeLGFName)) {
                                  if (component != null) {
                                      ModifiedVLayout modifiedVLayout = (ModifiedVLayout) component;
                                      modifiedVLayout.setData(record);
                                      return modifiedVLayout;
                                  } else
                                      return new ModifiedVLayout(record);
                              } else
                                  return null;
                          }
                      }
              
                      private class ModifiedVLayout extends VLayout {
                          private ListGridRecord record;
              
                          public ModifiedVLayout(ListGridRecord record) {
                              super(6);
                              this.record = record;
                              setHeight(50);
                              setWidth100();
              
                              Label testLabel = new Label();
                              testLabel.setContents(record.getAttributeAsString("scientificName"));
                              setMembers(testLabel);
                          }
              
                          public void setData(ListGridRecord record) {
                              this.record = record;
                          }
                      }
              
                      private class SecondLG extends ListGrid {
                          public SecondLG() {
                              setSelectionType(SelectionStyle.SINGLE);
                              setVirtualScrolling(true);
                              setShowRecordComponents(true);
                              setShowRecordComponentsByCell(true);
                              setPoolComponentsPerColumn(true);
                              setFixedRecordHeights(true);
                              setRecordComponentHeight(56);
                              setCanSort(false);
                              setCanPickFields(false);
                              setCanResizeFields(false);
                              setCanAutoFitFields(false);
                              setCanGroupBy(false);
                              setHeight100();
              
                              setAutoFetchData(false);
                              setDataSource("animals");
              
                              ListGridField lifeSpanLGF = new ListGridField("lifeSpan");
                              lifeSpanLGF.setCanEdit(true);
              
                              setFields(lifeSpanLGF);
              
                              setSort(new SortSpecifier[] { new SortSpecifier("lifeSpan", SortDirection.DESCENDING) });
                          }
                      }
                  }
              }

              Comment


                #8
                Apologies for the delay on this one - we see the issue and have a fix in testing - we'll update here when it hits builds.

                In the meantime, you can hook dataChanged on your first grid and call invalidateRecordComponents() - that's pretty slow, but should get things working as you expect while we get the fix in.
                Last edited by Isomorphic; 17 Sep 2018, 01:25.

                Comment


                  #9
                  No problem. I'll wait for your fix. Thank you!

                  Comment


                    #10
                    This is fixed and the change will appear in builds dated September 18 and later.

                    Comment


                      #11
                      It's working! Now recordComponents look better in 12.0 than in 6.1, well done!

                      Comment

                      Working...
                      X