Announcement

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

    Grid summaries not always showing in hover component

    SmartGWT 2.5

    We have a ListGrid where we have overridden getCellHoverComponent() to show another ListGrid with "child" records. The class that contains the main ListGrid is used in two different contexts. One is in a SectionStackSection and another is in a Window. The hover grid shows up just fine in both cases.

    The users have asked for a summary line to be added to the hover grid. So we added grid.setShowGridSummary(true). The summary line now shows up as expected in the first context, but not in the second.

    Is there some other setting that could possibly make the summary row not show? Here is the code that setup up the hover grid.
    Code:
    @Override
    protected Canvas getCellHoverComponent(Record record, Integer rowNum, Integer colNum) {
    	RecordList packContents = record.getAttributeAsRecordList(PACK_CONTENTS);;
    	if (packContents!=null && !packContents.isEmpty()) 
    		return getPackGrid(packContents);
    	else
    		return null;
    }
    /**
     * Returns a canvas to display as hover text for a prepack item.
     * @param packContents A RecordList of PoPackContents records to display
     * @return
     */
    private Canvas getPackGrid(RecordList packContents) {
    	ListGrid grid = new ListGrid();
    	grid.setDataSource(DataSource.get(IslandPacificDSConstants.DATASOURCE_PoPackContents));
    	grid.setFields(getPackGridFields(DataSource.get(IslandPacificDSConstants.DATASOURCE_PoPackContents).getFields()));
    	grid.setShowGridSummary(true);
    	grid.setData(packContents);
    	grid.setAutoFitData(Autofit.BOTH);
    	grid.setAutoFitFieldWidths(true);
    	grid.setLeaveScrollbarGap(false);
    	grid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
    	return grid;
    };

    #2
    Perhaps it's clipped off for some reason? Take a look with the Watch Tab and see if the grid's outline when clicked extends past the last visible pixel.

    Comment


      #3
      I can see the main grid in the watch tab, but not the hover component grid. The outline of the main grid is much larger that it needs to be for the entire hover component canvas to show up, so not clipping in that sense.

      Is there some way to see that? When I hover and it shows up the watch tab doesn't update.
      Last edited by jay.l.fisher; 27 Sep 2011, 11:47.

      Comment


        #4
        Click "Refresh" to update the Watch tab.

        Comment


          #5
          The hover component disappears when I switch to the dev console window to click "refresh".

          Comment


            #6
            Ah yes - you've stopped hovering and taken focus from the window, so it would hide.
            You could do the following:
            - modify the ListGrid definition to set an ID - say "hoverGrid"
            - modify the ListGrid definition to set "hoverAutoDestroy" to false
            - roll over the grid so the hover canvas shows up
            - pop open the dev console and evaluate "hoverGrid.show()" to bring it back up

            That'd allow you to do some debugging on the component in JavaScript - you could check whether "hoverGrid.summaryRow" is defined, is visible, is drawn, and at what size (using either the watch tab or by evaluating javascript to interact with the live components, calling "isDrawn()", "isVisible()", "getPageRect()", maybe "bringToFront()" to ensure the thing is drawn, visible and not occluded by other widgets, etc).

            Note: we also made an attempt to reproduce this issue on our end - code we used is pasted below-- and this worked for us.
            As always, if you can get us a reproducible case we can probably debug things pretty effectively, and the process of simplifying your app code into a quickie test case can also sometimes reveal what's going wrong if there's a bug in the app code.

            Code:
            import com.google.gwt.core.client.EntryPoint;
            import com.smartgwt.client.data.Record;
            import com.smartgwt.client.data.RecordList;
            import com.smartgwt.client.types.AutoFitWidthApproach;
            import com.smartgwt.client.types.Autofit;
            import com.smartgwt.client.types.ListGridFieldType;
            import com.smartgwt.client.widgets.Canvas;
            import com.smartgwt.client.widgets.grid.ListGrid;
            import com.smartgwt.client.widgets.grid.ListGridField;
            import com.smartgwt.client.widgets.grid.ListGridRecord;
            
            public class HoverGrid implements EntryPoint {
            
                @Override
                public void onModuleLoad() {
                    
                    ListGrid normalGrid = new ListGrid() {
                        @Override
                        protected Canvas getCellHoverComponent(Record record, Integer rowNum, Integer colNum) {
                            return getHoverGrid();
                        }
                    };
                    normalGrid.setHoverWidth(1);
                    normalGrid.setWidth(300);
                    normalGrid.setHeight(300);
                    normalGrid.setShowHoverComponents(true);
                    normalGrid.setCanHover(true);
                    
                    ListGridField f1 = new ListGridField();
                    f1.setName("f1");
                    
                    normalGrid.setData(new ListGridRecord[] { new ListGridRecord() {{setAttribute("f1", "A value");}}});
                    
                    normalGrid.setFields(f1);
                    
                    normalGrid.draw();
                    
                    
                }
                private ListGrid hoverGrid;
                public ListGrid getHoverGrid () {
                    if (hoverGrid != null) return hoverGrid;
                    ListGrid grid = new ListGrid();
            //        grid.setWidth(1);
                    grid.setID("hoverGrid");
                    grid.setHoverAutoDestroy(false);
                    ListGridField countField = new ListGridField("count");
                    countField.setType(ListGridFieldType.INTEGER);
                    grid.setFields(countField);
                    grid.setShowGridSummary(true);
                    RecordList data = new RecordList();
                    for (int i = 0; i < 5; i++) {
                        ListGridRecord r = new ListGridRecord();
                        r.setAttribute("count", i);
                        data.add(r);
                    }
                    
                    grid.setData(data);
                    grid.setAutoFitData(Autofit.BOTH);
                    grid.setAutoFitFieldWidths(true);
                    grid.setLeaveScrollbarGap(false);
                    grid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
                    hoverGrid = grid;
                    return grid;
                }
            
            }

            Comment

            Working...
            X