Announcement

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

    Redraw problems combining Live Grid and setShowRecordComponentsByCell()

    Using SmartGWT nightly build revision 1145. Running in GWT debug mode on Firefox 3.5.9 on Fedora 11. GWT 2.0.3

    I'm trying to combine the "Live Grid" and "Grid Cell Widgets" demos from the showcase and I'm running into a drawing problem in which the widgets I create get drawn in the wrong cell (see attached).

    The problem seems to be caused when the ListGrid attempts to render rows off-screen as you scroll to them. If I ensure all rows are pre-rendered by calling
    Code:
    setDrawAheadRatio(100.0f)
    the problem goes away, though that isn't a practical workaround obviously.

    The relevant code snippets are:

    Code:
    grid.setAutoFetchData(true);
    grid.setAlternateRecordStyles(true);
    grid.setShowRecordComponents(true);          
    grid.setShowRecordComponentsByCell(true);  
    grid.setDataSource(dataSource);
    .
    .
    .
    // In the class I inherited from ListGrid
       @Override  
        protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {  
    
            String fieldName = this.getFieldName(colNum);  
    
            if (fieldName.equals("actions")) {  
                IButton button = new IButton();  
                button.setHeight(18);  
                button.setWidth(85);                      
                button.setIcon("icons/tux.png");  
                button.setTitle(record.getAttribute("id") + " " + colNum);  
                button.addClickHandler(new ClickHandler() {  
                    public void onClick(ClickEvent event) {  
                        SC.say(" info button clicked.");  
                    }  
                });  
                return button;  
            } else {  
                return null;  
            }  
    
        }
    Attached Files

    #2
    I got the same problem.
    Is there anyway to solve this problem? Thanks.

    Comment


      #3
      Standalone test case

      Here is the complete code of a modification to the LiveGridFetchSample class from the sample gallery that exhibits the redraw problem.

      Code:
      public class LiveGridFetchSample implements EntryPoint {  
        
          public void onModuleLoad() {  
        
              RPCManager.setPromptStyle(PromptStyle.CURSOR);  
              DataSource dataSource = ItemSupplyXmlDS.getInstance();  
        
              ListGridField rowNum = new ListGridField("itemNum", "Item No.");  
              rowNum.setWidth(65);  
              rowNum.setCellFormatter(new CellFormatter() {  
                  public String format(Object value, ListGridRecord record, int rowNum, int colNum) {  
                      return rowNum +"";  
                  }  
              });  
        
              ListGridField itemName = new ListGridField("itemName", 100);  
              ListGridField sku = new ListGridField("SKU", 100);  
              ListGridField description = new ListGridField("description", 150);  
              ListGridField category = new ListGridField("category", 100);  
              ListGridField units = new ListGridField("units", 100);  
        
              ListGridField unitCost = new ListGridField("unitCost", 100);  
              unitCost.setType(ListGridFieldType.FLOAT);  
        
              ListGridField inStock = new ListGridField("inStock", 100);  
              inStock.setType(ListGridFieldType.BOOLEAN);  
        
              ListGridField nextShipment = new ListGridField("nextShipment", 100);  
              nextShipment.setType(ListGridFieldType.DATE);  
        
        
        
              final ListGrid listGrid = new ListGrid(){  
                  @Override  
                  protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {  
        
                      String fieldName = this.getFieldName(colNum);  
        
                      if (fieldName.equals("SKU")) {  
                          
                          IButton editImg = new IButton("Button");
                          editImg.addClickHandler(new ClickHandler() {  
                              public void onClick(ClickEvent event) {  
                                  SC.say("Edit Comment Icon Clicked for country : " + record.getAttribute("countryName"));  
                              }  
                          });  
                          
                          return editImg;
        
                      } else {  
                          return null;  
                      }  
        
                  }  
              };  
              
              listGrid.setWidth(800);  
              listGrid.setHeight(600);  
              listGrid.setAutoFetchData(true);  
              listGrid.setDataSource(dataSource);  
      
              listGrid.setShowRecordComponents(true);          
              listGrid.setShowRecordComponentsByCell(true);          
              
              listGrid.setFields(rowNum, itemName, sku, description, category, units, unitCost);  
        
              listGrid.draw();  
          }  
        
      }
      Attached Files
      Last edited by andrewr; 19 Apr 2010, 00:28.

      Comment


        #4
        Is there an issue in your bug database for this problem? If not, should I add one?

        Comment


          #5
          Use the latest build and also set

          listGrid.setRecordComponentPoolingMode("viewport");

          Read the a javadocs for this method. Note that the argument type is currently a String but will be changed to an enum.

          Sanjiv

          Comment


            #6
            That fixes the problem! Thank you very much for your reply.

            Comment

            Working...
            X