Results 1 to 2 of 2

Thread: Raise Event For Two or More Checkboxes

  1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    38

    Default Raise Event For Two or More Checkboxes

    I have an interesting situation. I have a form with some checkboxes and radio buttons. I need an event that will fire when 2 or more of these checkboxes are checked and will disable the corresponding radio buttons.

    Screen shot 2011-02-22 at 10.47.48 AM.jpg

    So in this case since checkbox 10 and 11 are clicked, I need radio button 10 and 11 enabled and the rest disabled/greyed out. Each of the checkboxes and radio buttons are created dynamically. I have tried using the checked event, but to be honest I do not really understand what I'm doing. I'd really appreciate if anyone could give me a little direction...

    I'm not putting much code here because there's a lot going on here. This form is actually created as the result of a button being clicked after two or more rows are checked on a grid...

    Code:
    namesStore.load({
                                callback:function (records, options, success) {
                                    //console.log(success); For FireBug
                                    if (success) {
                                        var ct = records.length, it = 0;
                                        
                                        while (it < ct) {
    
                                            Ext.getCmp('namesFieldset').add(new Ext.form.Checkbox({
                                                boxLabel:  " < " + checkedRecords[it].get('location') + " | " + checkedRecords[it].get('name') + " | " + checkedRecords[it].get('transliteration') + " | " + 
                                                checkedRecords[it].get('source') + " | " + checkedRecords[it].get('located_true') + 
                                                " > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; < " +
                                                records[it].get('name') + " | " + records[it].get('transliteration') + " | " + 
                                                records[it].get('source') + " | " + records[it].get('located_true') + " > ",
                                                id: checkedRecords[it].get('location'), listeners: {check: function getLocationsForDisplay(checkboxes, placeNamesApplyForm, plgrps) {
                                                    if(checkboxes.length == 2){
                                                      placeNamesApplyForm.cascade(function(cmp) {
                                                            for(var d = 0; d < plgrps.length; d++){
                                                                if (cmp.isXType('radio') && cmp.getId() != plgrps[d]) {
                                                                        cmp.disable();
                                                                }else if(cmp.isXType('radio') && cmp.getId() == plgrps[d]){
                                                                    cmp.enable();
                                                                }
                                                            }
                                                        });
                                                        }
                                                }}
                                            }));
    The getLocationsForDisplay() was my attempt to this. I was trying to see if I could pass some variables from outside the load(), which are probably out of scope and not what a checked handler expects. Hope someone can give me tips

    Thank you,

    elshae

  2. #2
    Sencha User
    Join Date
    Nov 2010
    Posts
    38

    Default

    Ok so I managed to get something...now when I click a checkbox the event fires, but it disables ALL my radio buttons!!! And it only seems to fire once?

    Code:
    namesStore.load({
                                callback:function (records, options, success) {
                                    //console.log(success); For FireBug
                                    if (success) {
                                        var ct = records.length, it = 0;
                                        
                                        while (it < ct) {
    
                                            Ext.getCmp('namesFieldset').add(new Ext.form.Checkbox({
                                                boxLabel:  " < " + checkedRecords[it].get('location') + " | " + checkedRecords[it].get('name') + " | " + checkedRecords[it].get('transliteration') + " | " + 
                                                checkedRecords[it].get('source') + " | " + checkedRecords[it].get('located_true') + 
                                                " > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; < " +
                                                records[it].get('name') + " | " + records[it].get('transliteration') + " | " + 
                                                records[it].get('source') + " | " + records[it].get('located_true') + " > ",
                                                id: checkedRecords[it].get('location'), listeners: {check: function (checkbox, value) {
                                                    if(value == true){
                                                        placeNamesApplyForm.cascade(function(cmp) {
                                                                for(var d = 0; d < checkedRecords.length; d++){
                                                                    if (cmp.isXType('checkbox') && cmp.getValue() && cmp.getId() == checkedRecords[d].get('location')) {
                                                                      Ext.getCmp(checkedRecords[d].get('place_group')).enable();
                                                                    }//end if
                                                                    else {
                                                                      Ext.getCmp(checkedRecords[d].get('place_group')).disable();
                                                                    }
                                                                }//end for
                                                        });                        
                                                    }//end if
                                                }}
                                            }));
                                      
                                            Ext.getCmp('displayFieldset').add(//new Ext.form.Radio({
                                                    {
                                                boxLabel:  "Location: " + checkedRecords[it].get('location') + " &nbsp;Source = " + 
                                                checkedRecords[it].get('source') + " &nbsp;Located True = " + checkedRecords[it].get('located_true'), 
                                                id: checkedRecords[it].get('place_group'), name: 'display',
                                                inputValue: checkedRecords[it].get('location') }
    
                                            //})
                                            );
                                            
                                            if(typeof records[it].get('distance') != 'undefined'){
                                                var distances = records[it].get('distance').split("|");
                                                for(var d = 0; d < distances.length; d++){
                                                    if(distances[d] != ""){
                                                        Ext.getCmp('distanceFieldset').add(new Ext.form.TextField({
                                                        value: distances[d], readOnly: true, width: 600}));
                                                    }
                                                }
                                            }
                                            it++;
                                        }
                                    }
                                    Ext.getCmp(checkedRecords[0].get('place_group')).setValue(true);
                                    placeNamesApplyWindow.show();
                                }
                        });
    elshae

Similar Threads

  1. How to raise event from xtype and capture it in parent?
    By dbassett74 in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 14 Jun 2009, 8:58 PM
  2. raise click event manually
    By jeusdi in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 21 Oct 2008, 4:18 AM
  3. How to raise on drop event on my panel i have extended?
    By ruggerboy in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 8 Sep 2008, 1:31 PM
  4. event's doesnt raise on updating innerHTML
    By adept07 in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 29 May 2008, 3:36 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •