1. #1
    Sencha User chrizmaster's Avatar
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    441
    Vote Rating
    1
    chrizmaster is on a distinguished road

      0  

    Default Problems while using direct to fill a combobox

    Problems while using direct to fill a combobox


    Hi,

    I have a combobox store:
    PHP Code:
     login.cmb_security_store = new Ext.data.DirectStore({
            
    directFn:AcSrvService.getUserRoles,     
            
    paramsAsHash:false,
            
    idProperty:'path',
            
    root:'',
            
    paramOrder: ['username'],
            
    fields:[
                {
    name:'displayname'}, 
                {
    name:'path'}
            ],
             
    listeners: {
                
    beforeload: function(storeoptions){
                    if (
    Ext.getCmp('username').getValue().length != 0) {
                        
    options.params.username Ext.getCmp('username').getValue();
                    }
                    else 
                        return;
                }
            } 
        }); 
    if i call login.cmb_security_store.load , it loads the data.
    This is the response from my backend:
    PHP Code:
    {"tid":3,"action":"AcSrvService","method":"getUserRoles","result":[{
          
    "displayname":"Archivnutzung","path":"/SYSTEM/ROLES/ARCHIVE"},{
          
    "displayname":"Datenerfassung","path":"/SYSTEM/ROLES/CAPTURE"},{
          
    "displayname":"Administration","path":"/SYSTEM/ROLES/ADMIN"}],"type":
      
    "rpc"
    For some reason, I just have hte first entry in my combobox (Archivnutzung), the other 2 entrys won't appear.
    Anyone knows why?

    Christian

  2. #2
    Sencha User chrizmaster's Avatar
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    441
    Vote Rating
    1
    chrizmaster is on a distinguished road

      0  

    Default


    is this problem really that difficult or why is nobody there who has a little hint for me? (i don't request a solution, just a little hint.. )

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,795
    Vote Rating
    602
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Are you sure the problem has anything to do with direct? What if you try and load it like:

    Code:
     login.cmb_security_store = new Ext.data.JsonStore({
            idProperty:'path',
            root:'',
            fields:[
                {name:'displayname'}, 
                {name:'path'}
            ],
             listeners: {
                beforeload: function(store, options){
                    if (Ext.getCmp('username').getValue().length != 0) {
                        options.params.username = Ext.getCmp('username').getValue();
                    }
                    else 
                        return;
                }
            },
            data: [{
          "displayname":"Archivnutzung","path":"/SYSTEM/ROLES/ARCHIVE"},{
          "displayname":"Datenerfassung","path":"/SYSTEM/ROLES/CAPTURE"},{
          "displayname":"Administration","path":"/SYSTEM/ROLES/ADMIN"}]
        });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Sencha User chrizmaster's Avatar
    Join Date
    Feb 2009
    Location
    Australia
    Posts
    441
    Vote Rating
    1
    chrizmaster is on a distinguished road

      0  

    Default


    Hi Evant,

    even if I copy your code to try it with local data, I don't see any results in the combobox.

    I've copied the combobox which I use, maybe I do something wrong in here:
    PHP Code:
    {
                    
    id                'cmb_security',
                    
    xtype            'combo',
                    
    bodyStyle        'padding:10px',
                    
    layout            'form',
                    
    store            :  login.cmb_security_store,
                    
    displayField    'displayname',
                    
    valueField        'path',
                      
    mode            'local',
                      
    triggerAction    'all',
                    
    typeAhead        true,
                    
    editable        false
    (-...-) 
    and here's the store again. (I've changed it a bit, but still no luck.

    PHP Code:
     login.cmb_security_store = new Ext.data.DirectStore({
            
    directFn:AcSrvService.getUserRoles,     
            
    paramsAsHash:false,
            
    autoLoad:true,
            
    reader: new Ext.data.JsonReader({
                
    root:             'data',
            
    fields:[
                {
    name:'displayname'}, 
                {
    name:'path'}
            ],
            }),
            
    paramOrder: ['username'],
             
    listeners: {
                
    beforeload: function(storeoptions){
                    if (
    Ext.getCmp('username').getValue().length != 0) {
                        
    options.params.username 'test';//Ext.getCmp('username').getValue();
                        
    login.cmb_security_store.removeAll()
                        
    Ext.getCmp("cmb_security").setValue("");
                    }
                    else 
                        return;
                },
                
    load    : function(ds,records,o){
                     
    console.log(ds,records,o);
                 if (
    records.length 0) {
                    
    Ext.getCmp("cmb_security").setValue(records[0].data.path);
                 }
                }
            } 
        }); 
    JSON CODE from Server: (Jslint says it's ok..)
    PHP Code:
    {"tid":2,"action":"AcSrvService","method":"getUserRoles","result":{"data":[{
            
    "displayname":"Archivnutzung","path":"/SYSTEM/ROLES/ARCHIVE"},{
            
    "displayname":"Datenerfassung","path":"/SYSTEM/ROLES/CAPTURE"},{
            
    "displayname":"Administration","path":"/SYSTEM/ROLES/ADMIN"}],
        
    "success":true},"type":"rpc"

  5. #5
    Ext JS Premium Member
    Join Date
    Mar 2010
    Location
    Finland
    Posts
    1
    Vote Rating
    0
    macke is on a distinguished road

      0  

    Default


    I think you need to return the data in a root key and maybe also return a totals field

    My response from direct looks like this:
    Code:
    {"type":"rpc","tid":2,"action":"user","method":"combo_query","result":{"total":3,"items":[{"id":1,"name":"XXX"},{"id":2,"name":"YYY"},{"id":3,"name":"ZZZ"}]}}
    In the store you need to set the root config in my case:

    Code:
    root: 'items'

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi