Announcement

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

    Set Tooltips for SelectItem items possible?

    There seem to be three methods for setting hovers on a SelectItem:
    Code:
    addItemHoverHandler
    setItemHoverFormatter
    setItemTitleHoverFormatter
    The first can be used to set a tooltip if the user hovers over the SelectItem item.
    The second or third I thought could be used to set a tooltip if the user hovers over a specific SelectItem item on an expanded SelectItem.
    However, the methods do not seem to have any function.
    Is it possible to set a tooltip if the user hovers over a specific SelectItem item on an expanded SelectItem at all?

    Thanks
    fatzopilot

    #2
    Are you using a databound SelectItem?

    Comment


      #3
      Yes, however, the actual display values for the SelectItem are obtained from a value map as the DS just provides an id.

      Comment


        #4
        Well the two ideas where either use getClientPickListData() on a non-data bound and setPrompt() on the ListGridRecords, or use a DataArrived handler to set do the same thing.

        Comment


          #5
          Hi svjard,

          yes, currently I use
          Code:
          reportTemplateSelector.addItemHoverHandler(new ItemHoverHandler() {  
          		            public void onItemHover(ItemHoverEvent event) {
          		                reportTemplateSelector.setPrompt(getReportTemplateDesriptionValueMap().get(reportTemplateSelector.getValue()));  
          		            }  
          		        });
          to achieve the same effect as in this showcase example:
          http://www.smartclient.com/smartgwt/showcase/#form_details_hovers
          (see also screenshot sh1.png):
          What I actually want to achieve (and could not find a way for) is shown in sh2.png (this is a mock).
          I don't see how getClientPickListData() or a DataArrived handler would help me out here :(
          Are there other options? For me it seems like this would make a nice feature request... ;)

          Cheers
          fatzopilot
          Attached Files

          Comment


            #6
            Well that drop down (the PickList) is nothing more then a ListGrid, and the valueMap is just list grid records. So in the same way you set hover's for a ListGrid, namely ListGridRecord.setPrompt(), you can do the same in this situation. All you need is to get the ListGridRecords hence the two methods I stated. I haven't tried it yet, but if run into any issue just post a followup.

            Comment


              #7
              Hi svjard,

              At least in my version of smartGWT (which is 2.2) the ListGridRecord.setPrompt() method is not existing, it's just there for ListGridFields...

              Cheers
              fatzopilot

              Comment


                #8
                Your right, the other way would be to setPickListFields() on the SelectItem, where the field you defined has basically the same setup as you would do in the ShowCase hover examples for the ListGrid.

                Comment


                  #9
                  Finally, I got it working, thanks to your help!

                  For the record, here is what I ended up with:
                  Code:
                  final SelectItem reportTemplateSelector = new SelectItem("reportTemplateID"){
                  	@Override
                  	public ListGridRecord[] getClientPickListData() {
                  		return (ListGridRecord[]) getReportTemplateRecordList().toArray();
                  	}
                  	
                  };
                  reportTemplateSelector.setAutoFetchData(false); //does fetch DS anyway, presumably because of set foreign key relationship
                  reportTemplateSelector.setValueField("reportTemplateID");
                  reportTemplateSelector.setDisplayField("templateName");
                  ListGridField nameField = new ListGridField("templateName");
                  nameField.setShowHover(true);
                  
                  //this is for the SelectItem item tooltips
                  nameField.setHoverCustomizer(new HoverCustomizer() {  
                  public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {  
                  	return record.getAttribute("description");  
                  }  
                  });
                  
                  //this is for the SelectItem tooltip 
                  reportTemplateSelector.addItemHoverHandler(new ItemHoverHandler() {  
                  public void onItemHover(ItemHoverEvent event) {
                  	reportTemplateSelector.setPrompt(getReportTemplateRecordList().getValueMap("reportTemplateID", "description").get(reportTemplateSelector.getValue()).toString());  
                  }  
                  });
                  
                  reportTemplateSelector.setPickListFields(nameField);
                  Thanks again!
                  fatzopilot

                  Comment


                    #10
                    I've spend 2 days on this problem, I'm setting data trought setValueMap(jso),
                    (this will work 4 datasource users also).

                    public class MyComboBox extends ComboBoxItem {

                    public MyComboBox() {
                    ...
                    ListGrid pickListProperties = new ListGrid();
                    /*
                    * @method gridRenderer.cellHoverHTML()(GridRenderer.js/ISC_Grids.js)
                    * StringMethod to dynamically assemble an HTML string to show in a hover window over the
                    * appropriate cell/record when this.canHover and this.showHover are both true.
                    * Called when the mouse hovers over a cell.
                    */
                    pickListProperties.setShowHover(true);
                    pickListProperties.setCanHover(true);
                    setPickListProperties(pickListProperties);
                    ...
                    }
                    ...
                    }

                    Opinions:
                    1 it looks too much stupid (and it definitely will kill IE ) have setPickListProperties(pickListProperties) API that requires ListGrid object !!!(that written in 12000 strings of Java source code !!!) for passing properties object 4 PickList.
                    2 Actually I just need to pass showHint:true to PickList from my MyComboBox constructor.
                    3 I can't use ListGridField for this purpose properly without combobox datasource - it works but shows only value fields/prompts instead of display fields/and same prompts:
                    ListGridField lgf = new ListGridField(getName()/*getValueFieldName()*/);
                    lgf.setShowHover(true);
                    setPickListFields(lgf);
                    4 ListGridField: HoverCustomizer / ListGrid: CellHoverHandler,HoverHandler,CellOverHandler also quite useless - I was unable to achieve my goal with their help
                    5 Many many more unsuccessfull attempts were by attempting to use native javascript. At least we can get "pickListFields" array, but there is no way to get hovered item.
                    6 I was able to get ComboBoxItem to work somehow properly only by downloading 2.3 LGPL night build (it suitable from 11 november)

                    Comment


                      #11
                      1. incorrect. What is happening is that just the properties you pass are being passed to the underlying PickList, which extends from ListGrid field. No expensive operation is being performed.

                      It's very difficult to follow the rest of what you've written. If you think you've found a bug, please create a minimal, standalone test case demonstrating the problem.

                      Comment

                      Working...
                      X