1. #1
    Ext User hossaindoula's Avatar
    Join Date
    Jan 2010
    Location
    Riyadh, K.S.A
    Posts
    8
    Vote Rating
    0
    hossaindoula is on a distinguished road

      0  

    Default How to get Value of CheckBox in GXT

    How to get Value of CheckBox in GXT


    I have a CheckBoxGroup and under that group I have multiple CheckBoxes... How can I get the checked value(s)??? I have done something like this:



    Code:
     
            final CheckBoxGroup chkGrp = new CheckBoxGroup();
            chkGrp.setFieldLabel("Section");
            CheckBox chkBxFld = new CheckBox();
            chkBxFld.setBoxLabel("Family Section");
            CheckBox chkBxFld1 = new CheckBox();
            chkBxFld1.setBoxLabel("Single Section");
            chkGrp.add(chkBxFld);
            chkGrp.add(chkBxFld1);
            fieldSet.add(chkGrp);
     
            String family_single = "";
            List<CheckBox> family_single_check_list = chkGrp.getValues();
            Iterator itr = family_single_check_list.iterator();
            while(itr.hasNext()){
               Object element = itr.next();
               family_single += element.toString() + "/";
            }

    The problem I am facing is the in the string varible "family_single" the CheckBox widget is also coming... Why the CheckBox comes inside a String??? Is there any other way to return the checked value of CheckBoxGroup in EXT-GWT(GXT)???

  2. #2
    Sencha User
    Join Date
    Jul 2009
    Posts
    37
    Vote Rating
    0
    tortexy is on a distinguished road

      0  

    Default


    You may check the sample:
    http://www.extjs.com/examples/explorer.html#gridbinding

    it does bind ModelData through FormBinding to a Form.

    It works the same way for checkboxes too.

  3. #3
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    0
    Arno.Nyhm is on a distinguished road

      0  

    Default


    Quote Originally Posted by hossaindoula View Post
    Why the CheckBox comes inside a String??? Is there any other way to return the checked value of CheckBoxGroup in EXT-GWT(GXT)???
    in your iterator you use object instead of casting it to checkbox ... that was the problem i think.



    ForumThread431617CheckBoxValues.PNG

    look at this code:

    PHP Code:
    CheckBox check1 = new CheckBox();
            
    check1.setBoxLabel("Brochures");
            
    check1.setValueAttribute("Bro");

            
    CheckBox check2 = new CheckBox();
            
    check2.setBoxLabel("Events");
            
    check2.setValue(true);
            
    check2.setValueAttribute("Ev");

            
    CheckBox check3 = new CheckBox();
            
    check3.setBoxLabel("Announcements");
            
    check3.setValue(true);
            
    check3.setValueAttribute("Ann");

            final 
    CheckBoxGroup checkGroup = new CheckBoxGroup();
            
    checkGroup.setFieldLabel("Subscribe");
            
    checkGroup.add(check1);
            
    checkGroup.add(check2);
            
    checkGroup.add(check3);
            
    fp.add(checkGroup);


            
    Button click = new Button("click");
            
    click.addSelectionListener(new SelectionListener<ButtonEvent>() {

                @
    Override
                
    public void componentSelected(ButtonEvent ce) {

                    
    String info "";
                    List<
    CheckBoxvalues checkGroup.getValues();
                    for (
    CheckBox checkBox values) {
                        
    info += "<br>" checkBox.getBoxLabel() + ": " checkBox.getValueAttribute() + " " checkBox.getValue();
                    }

                    
    MessageBox.alert("title"infonull);
                }
            }); 
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  4. #4
    Ext User hossaindoula's Avatar
    Join Date
    Jan 2010
    Location
    Riyadh, K.S.A
    Posts
    8
    Vote Rating
    0
    hossaindoula is on a distinguished road

      0  

    Default [SOLVED] CheckBox value retireve

    [SOLVED] CheckBox value retireve


    It is working... Thanx Arno.Nyhm...

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Posts
    12
    Vote Rating
    0
    ashly.jos@gmail.com is on a distinguished road

      0  

    Default To iterate through all the checkboxes

    To iterate through all the checkboxes


    hi,

    I got this working!! But, how do I iterate through all the checkboxes in the checkboxgroup?

    Thanks,
    -ash

  6. #6
    Sencha User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    867
    Vote Rating
    1
    micgala is on a distinguished road

      0  

    Default


    ??

    Haven't you seen the code above?

    PHP Code:
    List<CheckBoxvalues checkGroup.getValues(); 
                    for (
    CheckBox checkBox values) { 

  7. #7
    Sencha User
    Join Date
    Apr 2011
    Posts
    12
    Vote Rating
    0
    ashly.jos@gmail.com is on a distinguished road

      0  

    Default


    Hi micgala,

    Thanks for your comment.

    But, this part of code gives you only selected checkboxes, not the unselected ones.

    Anyways, I have figured out how to get all the checkboxes. Here is the code.

    Code:
                        List<Field<?>> fieldList = checkBoxGroup.getAll();
                        for(Field<?> fields : fieldList){
                            if(fields instanceof CheckBox){
                                CheckBox checkBox = (CheckBox) fields;
                            }
                         }
    Cheers,
    -ash

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar