1. #1
    Ext User
    Join Date
    Feb 2009
    Location
    UK
    Posts
    11
    Vote Rating
    0
    cdowey is on a distinguished road

      0  

    Default FieldSet CheckBoxToggle question

    FieldSet CheckBoxToggle question


    Hi all,
    I've created a form with two fieldsets, one of which uses a checkBoxToggle to show/hide it. When first displayed, I am populating the fieldsets with data pulled from the server. The problem is that I need to be able to programmatically toggle the checkbox, depending on the data received from the server. I can programmatically collapse/expand the fieldset ok but the checkbox itself is not checked when I expand the fieldset - is there a way to do this?

    Thanks.

  2. #2
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Not an easy one. But i just implemented it. Maybe it will be part of the next release.

  3. #3
    Ext User
    Join Date
    Feb 2009
    Location
    UK
    Posts
    11
    Vote Rating
    0
    cdowey is on a distinguished road

      0  

    Default


    Oh dear, is there any workaround I can use in the meantime? Your reply suggests there may not be though...

  4. #4
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Check your PMs. I just sent you the override.

  5. #5
    Ext User
    Join Date
    Feb 2009
    Location
    Sofia, Bulgaria
    Posts
    1
    Vote Rating
    0
    dwebwarm is on a distinguished road

      0  

    Default


    Hi sven,

    I'm just looking for a similar functionality. Actually I need to activate the checkboxToggle field if any of the fields within the fieldset is selected. Can you give me please some ideas how to implement it?

    Thanks in advance for your support.

  6. #6
    Ext User
    Join Date
    Nov 2008
    Location
    Russia, Siberia, Krasnoyarsk
    Posts
    23
    Vote Rating
    0
    dima_toxsoft is on a distinguished road

      0  

    Default


    Hi, sven!
    Please post this workaround here, i search for it too.
    Thanks in advance.

  7. #7
    Ext User
    Join Date
    Mar 2009
    Location
    France, Montpellier
    Posts
    8
    Vote Rating
    0
    a1ex is on a distinguished road

      0  

    Default


    Hello,

    this old thread is corresponding to my problem. No workaround has be posted (or i don't find it)
    I'm using a FieldSet with checkBoxToggle.

    Can the checkbox be checked when the fieldset is expanded ??

    Code:
        FieldSet fieldSet = new FieldSet();  
        fieldSet.setHeading(" FieldSet title");
        fieldSet.setCheckboxToggle(true);  
        fieldSet.setExpanded(true);
    
        // something like that would  be so nice  :) 
        fieldSet.setCheckboxChecked(true);
    I'm using gxt 1.2.4.

    Can i do that with this version ?

    Thanks in advance.

  8. #8
    Ext User
    Join Date
    Nov 2008
    Location
    Russia, Siberia, Krasnoyarsk
    Posts
    23
    Vote Rating
    0
    dima_toxsoft is on a distinguished road

      0  

    Default


    Hi A1ex!
    Sven didn't send me anything. I solve this problem very silly, create in project my classes FiledSet and FiledSetEvent. Copy/past origin GXTcode and add method public InputElement getCheckbox() {
    return checkbox;
    }
    It very ugly, but it works.
    I hope this help.

  9. #9
    Ext User
    Join Date
    Mar 2009
    Location
    France, Montpellier
    Posts
    8
    Vote Rating
    0
    a1ex is on a distinguished road

      0  

    Default


    hum ... and is it working ?
    How do you manipulate de checkbox InputElement ?

    Because when I look in the FieldSet code, I see the checkbox is checcked in the onRender.

    Code:
     
    protected void onRender(Element parent, int pos) {
        setElement(DOM.createFieldSet(), parent, pos);
        sinkEvents(Event.ONCLICK);
    
        Element legend = DOM.createLegend();
        legend.setClassName("x-fieldset-header");
    
        if (checkboxToggle) {
          checkbox = DOM.createInputCheck().cast();
    
          if (checkboxName != null) {
            checkbox.setAttribute("name", checkboxName);
          }
          legend.appendChild(checkbox);
          checkbox.setChecked(!collapsed);
        }
    ...
    I traced it with my debugger, I tried to force it at true.
    Then i tried to create my own FiedlSet classe with a setChecked method, like this :

    Code:
      public void setChecked(boolean checked) {
          this.checkbox.setChecked(checked);
      }
    and nothing appened better

    Then I tried the code of the example here (http://extjs.com/examples/forms/forms.html) and ....
    no checked checkbox.

    So I really don't understand what's wrong with this checkbox ??!!
    Or what's wrong with my code.

  10. #10
    Ext User
    Join Date
    Nov 2008
    Location
    Russia, Siberia, Krasnoyarsk
    Posts
    23
    Vote Rating
    0
    dima_toxsoft is on a distinguished road

      0  

    Default


    Hi, A1ex.
    Yes, it works, here is sample from my code:
    ...
    // set field checked
    statusFieldSet.expand();
    setCheckedFieldSet( statusFieldSet, true );

    // set field unchecked
    timeIntervalFieldSet.collapse();
    setCheckedFieldSet( timeIntervalFieldSet, false );
    ...

    private void setCheckedFieldSet(FieldSet aFieldSet, Boolean isChecked) {
    if(aFieldSet.getCheckbox() != null) {
    aFieldSet.getCheckbox().setChecked( isChecked );
    }
    }

    One moment, i use gxt version 1.2.2

    Hope, this help.