Announcement

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

    Hover warp for row/cell misbehaves

    I am trying to implement a hover text for when a user moves mouse over a ListGrid record to show some extra information that I do not want to be part of the ListGrid itself. I have successfully implemented the RowHoverHandler mechanism, but when I try to define that I do not want the hover text to wrap, I hit a wall.

    A simple code case of what I am trying to achieve and what I get can be seen below and in the attached files. I am using latest svn smartgwt code and GWT 2.0.4 (dev and host modes), Chrome dev latest and FF 3.6.8 under Linux Ubuntu 10.04.1 LTS.

    Code:
    	@Override
    	public void onModuleLoad() {
    		Canvas canvas = new Canvas();
    
    		final ListGrid countryGrid = new ListGrid();
    		countryGrid.setWidth(500);
    		countryGrid.setHeight(224);
    		countryGrid.setShowAllRecords(true);
    		countryGrid.setAlternateRecordStyles(true);
    		countryGrid.setCanHover(true);
    		countryGrid.setHoverWrap(false);
    
    		ListGridField nameField = new ListGridField("countryName", "Country");
    		ListGridField continentField = new ListGridField("continent", "Continent");
    		ListGridField countryCodeField = new ListGridField("countryCode", "Country Code");
    
    		countryGrid.setFields(nameField, continentField, countryCodeField);
    
    		countryGrid.setCanResizeFields(true);
    		countryGrid.setData(CountryData.getRecords());
    		
    
    		countryGrid.addRowHoverHandler(new RowHoverHandler() {
    			
    			@Override
    			public void onRowHover(RowHoverEvent event) {
    				countryGrid.setHoverCustomizer(new HoverCustomizer() {
    					
    					@Override
    					public String hoverHTML(Object value, ListGridRecord record, int rowNum,
    							int colNum) {
    						GWT.log("On Hover!");
    						return hoverText;
    					}
    				});
    				
    			}
    		});
    		
    		canvas.addChild(countryGrid);
    		canvas.draw();
    
    	}
    Attached Files

    #2
    See setHoverWidth(). Default width is 100px.

    Comment


      #3
      Yes I have seen that, but I do not want to define a width. I want it to not wrap and behave like the tooltip wrap, where width doesn't have to be defined.

      Comment


        #4
        You can place tooltip inside HTML element with 'nowrap'. Like this:

        Code:
                nameField.setHoverCustomizer(new HoverCustomizer() {
                    @Override
                    public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                        String tooltip = "my long-long tooltip content";
                        return "<div style=\"white-space:nowrap;\">"+tooltip+"</div>";
                    }
                });

        Comment


          #5
          Very good idea. Not the support I would expect from the API, but a good workaround instead. Thanks for your insight.
          Last edited by ghost277; 5 Oct 2010, 10:05.

          Comment

          Working...
          X