Results 1 to 2 of 2

Thread: doLayout Problem adding a radiogroup dynamically

  1. #1

    Default doLayout Problem adding a radiogroup dynamically

    Hello everybody, I've a real big problem with this code.....I hope someone could help me

    Here is the code:

    Code:
    var lettore = new Ext.data.ArrayReader({}, [
       {name: 'id_commessa'},
       {name: 'descrizione_commessa'},
       {name: 'id_ordine'}, 
       {name: 'id_posizione'},
       {name: 'descrizione_posizione'},
       {name: 'id_fattura'}
    ]);
    
    
    var radioArray = [];
    
    var store_appr_tecn = new Ext.data.GroupingStore({
            reader: lettore,
            sortInfo:{field: 'descrizione_commessa', direction: "ASC"},
            groupField:'id_fattura'
        });
    
    //sul load dello store approvazione tecnica creo un array per il radiogroup
    store_appr_tecn.on('load',function(){
        var contatore = 0;
        var fattura_base = -1;
        this.each(function(record){
            var fattura_attuale = record.get('id_fattura');
            if(fattura_base != fattura_attuale){
                fattura_base = fattura_attuale;
                //il campo name  fondamentale se si vuole una selezione mutuamente esclusiva
                radioArray.push({boxLabel: 'Fattura '+record.get('id_fattura'), name: 'Fattura', inputValue: record.get('id_fattura')});
                contatore = contatore + 1;       
            }
        })    
        
        if (contatore != 0){
            sup_dx_inf_panel.removeAll();
            sup_dx_inf_panel.add(radioGroupFatture); //aggiungo dinamicamente la checkgroup che si popola dopo il load dello store
            sup_dx_inf_panel.doLayout();//forzo a ricaricare il layout
        }
        
            
        if(contatore == 0){
            finestraAvviso('Non hai nessuna richiesta di approvazione tecnica in sospeso','Informazione');
        }
        else if(contatore == 1) {
            finestraAvviso('Attenzione, hai ancora in sospeso '+contatore+' richiesta di approvazione tecnica','Informazione');
        }
        else{
            finestraAvviso('Attenzione, hai ancora in sospeso '+contatore+' richieste di approvazioni tecniche','Informazione');
        }
    });

    As you can see I have a groupingStore........and at the beginning (at the first load) I have no problem


    After that I make an AjaxRequest and on the success I made the store.removeAll and store.loadData

    Ok, here comes the problem......when I reach the code line

    sup_dx_inf_panel.doLayout()


    I obtain this error on firebug:

    uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOM3Node.compareDocumentPosition]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://192.168.42.210/act_man/devel/...-base-debug.js :: <TOP_LEVEL> :: line 1906" data: no]


    On the net I found a similar issue:
    http://stackoverflow.com/questions/5...abpanels-extjs


    But I don't use static IDs (or at least I don't think so)


    here is radioGroupFatture:

    Code:
    var radioGroupFatture = new Ext.form.FieldSet({
            //xtype: 'fieldset',
            title: 'Lista Fatture (Cliccare per espandere)',
            autoHeight: true,
            layout: 'auto',
            collapsed: true,   // initially collapse the group
            collapsible: true,
            items:[{
                xtype: 'radiogroup',
                columns: 5,
                items: radioArray,
                listeners:{
                    change: function(gruppo, singolo){
                        if (parseInt(singolo.inputValue) != null){
                            sup_dx_inf_panel.buttons[1].setDisabled(false);  
                        }
                        else{
                            sup_dx_inf_panel.buttons[1].setDisabled(true);     
                        }
                    }
                }        
            }]        
        });

    Could someone help me......I'm a newbie

    Sorry for my english and thanks everybody

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    Calling removeAll() is destroying the fieldset and the radiogroup. You're then trying to add the same fieldset (which is now destroyed) to the panel. Hence boom.

    You have two options...

    1. Don't remove the fieldset from the panel. Instead remove the items from the fieldset and then add the new items to the fieldset.
    2. Continue to remove the fieldset from the panel and create a new fieldset each time. Add that to the panel.


    You can't update radioArray and expect the fieldset to pick that up, it won't. Even if it did work you'd have problems because you never remove items from the array so it'd keep growing and growing.

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
  •