Threaded View

  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    17
    Vote Rating
    0
    Answers
    1
    Madiyana is on a distinguished road

      0  

    Default Answered: Store in a function

    Answered: Store in a function


    Hi,
    I am a new user in ExtJS4 and I have a problem that i can't resolve..
    I wanna put in a function this code :
    Code:
        
    var storeLD01_Objet = Ext.create('Ext.data.Store', {
            fields      :['id', 'libelle'],
            labelWidth      :150,
            proxy: {
                 type: 'ajax',                            
                 url: '/value/TypeAmenrecherche/search',
                 reader: {
                     type: 'json',
                     root: 'elt'
                }
            },
            listeners: {
                'load': function(store, operation, options){
                    this.insert(0, {id:'--', libelle:'--'});                
                }
            },
         autoLoad: true
        });
    My objective is to have a function like :
    function loadstore(link){
    ...
    url: '/gtrte/link/search',
    ...
    } because I want have a dynamic store who change with my value "link"

  2. Thank's.. It'is work now but when i used i can't do a selection in my combobox and i don't know why ..
    Code:
        var LD00_Nature = Ext.create('Ext.form.ComboBox', {
            id              :'nature',
            fieldLabel      :'Nature',
            labelWidth      :80,
            store: storeLD00_Nature,
            queryMode       :'remote',
            displayField    :'libelle',
            valueField      :'libelle',
            emptyText       :'--',
            editable        :false,
            listeners        : {
                select    : function(liste, index){
                    if(liste.value=='Amenagement'){
                        storeLD01_Objet.getProxy ().url = '/gedeo/TypeAmenagement/recherche/', 
                        storeLD01_Objet.load ();    
                      }
                    if(liste.value=='Milieu'){
                        storeLD01_Objet.getProxy ().url = '/gedeo/TypeMilieu/recherche/', 
                        storeLD01_Objet.load ();
                      }
                }            
            },
            border: 1
        });
    
    
       var storeLD01_Objet = Ext.create('Ext.data.Store', {
            fields      :['id', 'libelle'],
            labelWidth      :150,
            proxy: {
                 type: 'ajax',                            
                  reader: {
                     type: 'json',
                     root: 'elt'
                }
            },
            listeners: {
                'load': function(store, operation, options){
                     this.insert(0, {id:'--', libelle:'--'});                
                }
            },
         autoLoad: true
        });
    Can you tell me the problem please?
    Thank you very much

Thread Participants: 1

Tags for this Thread