Announcement

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

    Disable a radio button in a radioGroupItem

    Hello,

    I would like to disable a specific radio button in a radioGroupItem object. The method "setValueDisable(Object value,Boolean disable)" allows to do that normally, but I can't find how use it. This code returns me a fatal error :

    RadioGroupItem groupItem = new RadioGroupItem();
    groupItem.setValueMap("radio 1","radio 2");
    groupItem.setValueDisabled("radio 2", false);

    The begining of returned error is :

    com.google.gwt.core.client.JavaScriptException: (TypeError): self.setValueDisabled is not a function
    fileName: http://localhost:8888
    lineNumber: 3 etc...

    Someone have an idea of the problem?

    Thanks a lot

    #2
    What version of smartgwt are you running?

    Comment


      #3
      I run Smart GWT 2.1, the last release.

      Comment


        #4
        Originally posted by nicotik
        Hello,

        I would like to disable a specific radio button in a radioGroupItem object. The method "setValueDisable(Object value,Boolean disable)" allows to do that normally, but I can't find how use it. This code returns me a fatal error :

        RadioGroupItem groupItem = new RadioGroupItem();
        groupItem.setValueMap("radio 1","radio 2");
        groupItem.setValueDisabled("radio 2", false);

        The begining of returned error is :

        com.google.gwt.core.client.JavaScriptException: (TypeError): self.setValueDisabled is not a function
        fileName: http://localhost:8888
        lineNumber: 3 etc...

        Someone have an idea of the problem?

        Thanks a lot
        Currently RadioGroupItem.setValueDisabled(..) can only be called when the DynamicForm that it belongs to has been drawn. For now you can add the line of code
        groupItem.setValueDisabled("radio 2", false);

        within a DynamicForm.addDrawHandler(..).

        Sanjiv

        Comment


          #5
          Thank you for your aswner sjivan.
          Do you know if there is a way to make invisible a radio button?

          Comment


            #6
            Originally posted by sjivan
            Currently RadioGroupItem.setValueDisabled(..) can only be called when the DynamicForm that it belongs to has been drawn. For now you can add the line of code
            groupItem.setValueDisabled("radio 2", false);

            within a DynamicForm.addDrawHandler(..).

            Sanjiv
            After one year and with update SmartGWT 2.4 this problem seem to persist yet.
            Even with the following code
            Code:
            aDynamicForm.addDrawHandler(new DrawHandler() {
              @Override
              public void onDraw(DrawEvent event) {
                  groupItem.setValueDisabled("radio 2", false);
              }
            })
            seems not not work.

            Inspecting ISC_Form.js we can see the groupItem.setValueDisabled(value,disabled) calls itemForValue(value).
            Well, groupItem.itemForValue(value) refers to this["_radioItem" + value]; (where "_radioItem" in the minified wersion is "$540" string) but, with firebug, this not contains "_radioItem" + value element.
            I've force the item to be isc_RadioItem0 to force the setValueDisabled to call isc_RadioItem0.setDisable(false).
            Moreover, analyzing the call stack the radioGroupItem.update seems to put all inner RadioItem's disabled status equals to the radioGroupItem.disabled status.
            Last edited by bubus_company; 16 May 2011, 02:25.

            Comment


              #7
              Using 3.0

              for me it is working if you call redraw() once in onDraw handler.

              By the way: Would be nice to support API to use on initializing of SectionItem.
              Calling redraw after setting disabledValue in addDrawHandler seems not correct to me.

              My code looks like the one above.
              Last edited by damend; 11 Jan 2012, 06:43.

              Comment


                #8
                We've made a change that should resolve this - now calling 'setValueDisabled' before (or after) draw is supported, with no need to call redraw.
                This will show up in the 3.1d and 3.0p branches going forward.

                RE The request about hiding a radioItem: this would typically be handled by just calling 'setValueMap()' and changing the set of visible options.

                RE SectionItems: We're not sure what you're asking for here. There's already SectionItem.setDisabled(...). Is that not behaving as expected for you? Can you post a test case that demonstrates the problem you're experiencing?

                Comment


                  #9
                  Nice, thanks for enhancing API for us !

                  I meant RadioButton instead of SelectItem, so everything is fine!

                  Comment

                  Working...
                  X