Announcement

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

    How to set a id to a certain Widget or getElement()

    I wann use DOM to change some properties of a widget, but I've no idea how to setID to a Widget or getID from a Widget. In gwt, I can call widget.getElement to get the Element. But smartgwt doesn't support this method.
    Thx

    #2
    Followed is the code in gwt.
    Code:
    final Element elt=textArea.getElement();
    DOM.setElementProperty(elt,"scrollTop",DOM.getElementProperty(elt, "scrollHeight"));
    How can change it to run in smartgwt

    Comment


      #3
      Smart GWT abstracts the DOM structure and provides API's that work consistently across browsers so you should try not manipulating the DOM of Smart GWT widgets. Can you explain what you're trying to accomplish?

      Sanjiv

      Comment


        #4
        I want to change the position of scrollbar in TextAreaItem.

        In DOM, I can use scrollTop=scrollHeight. But I‘ve no idea, how to realize it in smartgwt.

        Thx

        Comment


          #5
          What about
          Code:
          public void setID(java.lang.String id)
          method of class BaseWidget.

          http://www.smartclient.com/smartgwt/...aseWidget.html

          Comment


            #6
            This setID is only for BaseWidget, not for TextAreaItem

            Comment


              #7
              Every widget extends BaseWidget so every widget has that method.

              Comment


                #8
                TextAreaItem doesn't extend from BaseWidgt
                Code:
                 
                java.lang.Object
                  extended by com.smartgwt.client.core.JsObject
                      extended by com.smartgwt.client.core.DataClass
                          extended by com.smartgwt.client.core.RefDataClass
                              extended by com.smartgwt.client.widgets.form.fields.FormItem
                                  extended by com.smartgwt.client.widgets.form.fields.TextAreaItem
                And in smartgwt javadoc, the setID method isn't found from Class TextAreaItem.

                Comment


                  #9
                  Has anyone found the solution to this problem? I'm trying to do the same thing because I want to integrate a TextItem with a third-party pure-Javascript control.

                  I find the fact that the various FormItem controls are not part of the normal widget hierarchy baffling.

                  Comment


                    #10
                    A third-party JavaScript control messing with the input element generated by a TextItem is very, very unlikely to work (just like all the other use cases where people think getting to the SmartGWT-generated DOM is a good idea).

                    Generating your own, separate HTML for the <input> is much more likely to work.

                    Comment


                      #11
                      Actually, on further reflection what I _really_ need to do is this: get the element ID attribute of any FormItem control. For example, the generated HTML for a FormItemIcon looks like this:

                      Code:
                      <img border="0" align="TEXTTOP" width="18" height="18" 
                        suppress="TRUE" 
                        style="vertical-align: middle; margin-top: 0px; margin-bottom: 0px;"     
                        id="isc_9C" 
                        src="http://127.0.0.1:8888/images/icons/calendar_Disabled.png"/>
                      Is there an in-code way of finding out that the 'id' attribute is "isc_9C" here? The reason I want to know it is so that I can pass it to the constructor of a third-party Javascript control I'm using.

                      Comment


                        #12
                        Thanks for the prompt reply. That makes sense. I'll just have to do the work to style the control so it looks like the other SmartGWT ones.

                        Comment

                        Working...
                        X