Announcement

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

    ComboBoxItem / SelectItem + RollOverCanvas / setShowRollOverCanvas possible?

    Hi Isomorphic,

    is RollOverCanvas as part of a ComboBoxItem (or SelectItem) that I set up with setPickListProperties(ListGrid with @Override getRollOverCanvas) possible? It does not work for me currently and I'm not sure if the error is on my behalf or if it is not possible at all.
    This most likely relates to this question.

    I'm using current 5.0p.

    Thank you & best regards
    Blama

    #2
    No, not possible. In general, Override methods don't work with setSomethingProperties() APIs.

    Comment


      #3
      Hi Isomorphic,

      thanks for the answer. I solved my usecase now with ListGrid.setCanHover(true) and ListGridField.setHoverCustomizer(), which might be better from an UI perspective anyway.

      Nevertheless I looked up ListGrid.setDefaultProperties() (and other X.setDefaultProperties(), the only setSomethingProperties() API I used so far) and it has this very informative Javadoc:
      Originally posted by docs
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.
      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.
      Out of interest I then tried to subclass ListGrid and feed that ListGrid-subclass instance to my ComboBoxItem's setPickListProperties().
      Code:
      private class TestGrid extends ListGrid {
      	private HLayout rollOverCanvas;
      	private ListGridRecord rollOverRecord;
      
      	public TestGrid() {
      		super();
      	}
      
      	@Override
      	protected Canvas getRollOverCanvas(Integer rowNum, Integer colNum) {
      		rollOverRecord = this.getRecord(rowNum);
      
      		if (rollOverCanvas == null) {
      			rollOverCanvas = new HLayout(3);
      			rollOverCanvas.setSnapTo("TR");
      			rollOverCanvas.setWidth(50);
      			rollOverCanvas.setHeight(22);
      
      			ImgButton editImg = new ImgButton();
      			editImg.setShowDown(false);
      			editImg.setShowRollOver(false);
      			editImg.setLayoutAlign(Alignment.CENTER);
      			editImg.setSrc("silk/comment_edit.png");
      			editImg.setPrompt("Edit Comments");
      			editImg.setHeight(16);
      			editImg.setWidth(16);
      			editImg.addClickHandler(new ClickHandler() {
      				public void onClick(ClickEvent event) {
      					SC.say("Edit Comment Icon Clicked for country : " + rollOverRecord.getAttribute("countryName"));
      				}
      			});
      
      			ImgButton chartImg = new ImgButton();
      			chartImg.setShowDown(false);
      			chartImg.setShowRollOver(false);
      			chartImg.setLayoutAlign(Alignment.CENTER);
      			chartImg.setSrc("silk/chart_bar.png");
      			chartImg.setPrompt("View Chart");
      			chartImg.setHeight(16);
      			chartImg.setWidth(16);
      			chartImg.addClickHandler(new ClickHandler() {
      				public void onClick(ClickEvent event) {
      					SC.say("Chart Icon Clicked for country : " + rollOverRecord.getAttribute("countryName"));
      				}
      			});
      
      			rollOverCanvas.addMember(editImg);
      			rollOverCanvas.addMember(chartImg);
      		}
      		return rollOverCanvas;
      	}
      };
      This did not work either. Is this supposed to work?
      If not, it would be great if you could add that information to ComboBoxItem.setPickListProperties() and SelectItem.setPickListProperties().

      Best regards
      Blama

      Comment


        #4
        No, not expected to work, that's just another way of trying to pass a method override and all such ways will fail (anonymous or inner classes too, for example).

        Comment


          #5
          OK, thank you.

          Comment

          Working...
          X