Announcement

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

    TreeGrid tooltip doesn't show text I set, it shows node image & connectors instead

    Good afternoon, dear smartgwt gurus!

    My aim is to show different tooltip for every tree node when user hovers mouse over it. For this I'm doing it:
    Code:
    TreeGrid tg = new TreeGrid();
    tg.setHoverMoveWithMouse(true);
    tg.setCanHover(true);
    tg.setShowHover(true);
    tg.setHoverOpacity(75);
    
    tg.addRowHoverHandler(new RowHoverHandler()
    {
        @Override
        public void onRowHover(RowHoverEvent event)
        {
            ListGridRecord lgr = event.getRecord();
            if(lgr instanceof TreeNode)
            {
                TreeNode hoveredTreeNode = (TreeNode)lgr;
                tg.setPrompt("the name is: <BR>" + hoveredTreeNode.getName());
            }
        }
    });
    And I always see the node image in a tooltip, not the text which I set, like this:


    BUT if I do this(i.e. remove tg.setCanHover(true)):
    Code:
    TreeGrid tg = new TreeGrid();
    tg.setHoverMoveWithMouse(true);
    tg.setHoverOpacity(75);
    tg.setPrompt("the name is: <BR> NAME");
    the tooltip text does appear instead of this node image, BUT it appears for the whole TreeGrid and also if I don't set canHover to true, hover events for rows and columns won't be fired, but I need it.

    Can anybody advise anything to me?

    Please, tell me, how can I replace content of the tooltip from the screenshot above? How can I show different tooltips for every node(row)? I've searched all the showcase and didn't find any examples for that. Example with tooltip in ListGrid works fine, but mine - doesnt, although I do the same things...

    Thanks in advance!

    #2
    Any suggestions about this question? Is it a bug or feature? How to solve it?

    Comment


      #3
      I've created a new small project, which you can run on your machine to check subject issue.

      Here it is:
      Code:
      package myapp.client;
      
      import com.google.gwt.core.client.EntryPoint;
      
      import com.smartgwt.client.types.TreeModelType;
      import com.smartgwt.client.util.SC;
      import com.smartgwt.client.widgets.grid.ListGridRecord;
      import com.smartgwt.client.widgets.grid.events.RowHoverEvent;
      import com.smartgwt.client.widgets.grid.events.RowHoverHandler;
      import com.smartgwt.client.widgets.layout.VLayout;
      import com.smartgwt.client.widgets.tree.Tree;
      import com.smartgwt.client.widgets.tree.TreeGrid;
      import com.smartgwt.client.widgets.tree.TreeNode;
      
      public class MyApp implements EntryPoint
      {
          private VLayout                mainVL                = new VLayout();                           
          private TreeGrid               fieldsTG          = new TreeGrid();
      
          public void onModuleLoad()
          {
              prepareFieldsTG();
              mainVL.addMember(fieldsTG);
              mainVL.setMargin(5);
              mainVL.setWidth100();
              mainVL.setHeight100();
              mainVL.draw();
          }
      
          private void prepareFieldsTG()
          {
              Tree smartGwtTree = new Tree();
              smartGwtTree.setNameProperty("Name");
              smartGwtTree.setModelType(TreeModelType.PARENT);
              smartGwtTree.setShowRoot(false);
              TreeNode rootNode = new TreeNode("ROOT");
              smartGwtTree.setRoot(rootNode);
              
              TreeNode newNode = new TreeNode("Node1");
              smartGwtTree.add(newNode, rootNode);
              newNode = new TreeNode("Node2");
              smartGwtTree.add(newNode, rootNode);
              TreeNode subNode = new TreeNode("SubNode1");
              smartGwtTree.add(subNode, newNode);
              
              fieldsTG.setHoverMoveWithMouse(true);
              fieldsTG.setCanHover(true);
              fieldsTG.setShowHover(true);
              fieldsTG.setHoverOpacity(75);
              
              fieldsTG.addRowHoverHandler(new RowHoverHandler()
              {
                  @Override
                  public void onRowHover(RowHoverEvent event)
                  {
                      ListGridRecord lgr = event.getRecord();
                      
                      if(lgr instanceof TreeNode)
                      {
                          TreeNode hoveredTreeNode = (TreeNode)lgr;
                          fieldsTG.setPrompt("You hovered on the node with name " + hoveredTreeNode.getName());
                          // FIXME: make it available to show promt which was set above in the tooltip canvas! Now it doesn't work!
                      }
                      else
                      {
                          SC.say("Hovered LGR is NOT a tree node!");                            
                      }
                  }
              });
              
              fieldsTG.setIndentSize(10);
              fieldsTG.setShowConnectors(true);                
              fieldsTG.setData(smartGwtTree);
              fieldsTG.getData().openAll();
              fieldsTG.setShowHeader(false);
              fieldsTG.setEmptyMessage("<br>No elements were found");
              fieldsTG.setHeight100();
              fieldsTG.setWidth(501); // TODO: somewhy if value is <= 200 - tree is not shown. Else - it's shown
          }
      }

      Comment


        #4
        Please post all relevant versions (see FAQ). If this wasn't tested in the latest version, please try it there first.

        Comment


          #5
          Originally posted by Isomorphic
          Please post all relevant versions (see FAQ). If this wasn't tested in the latest version, please try it there first.
          Sorry, I've forgot to do it this time.

          I'm using smartwgt 2.2 (just downloaded this version and tried it there), GWT SDK 2.0.3 with Eclipse 3.5 SR1 and jdk 1.6.0 u18 from Windows 7 Enterprise x64 and Mozilla Firefox 3.5.9 as browser.

          Can you advise me anything?

          Comment


            #6
            Hi J-Pro,
            I ran into the same problem and fixed using setHoverCustomizer:

            Code:
            TreeGrid tg = new TreeGrid();
            tg.setHoverMoveWithMouse(true);
            tg.setCanHover(true);
            tg.setShowHover(true);
            tg.setHoverOpacity(75);
            tg.setHoverCustomizer(new HoverCustomizer() {
            	@Override
            	public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
            		if(recordinstanceof TreeNode)
            	        {
            			TreeNode hoveredTreeNode = (TreeNode)record;
            			return "the name is: <BR>" + hoveredTreeNode.getName();
            		}
            		else
            		{
            			return "";// should not happen
            		}
            	}
            });

            Comment

            Working...
            X