Results 1 to 4 of 4

Thread: [Solved] ComboBox valueField,displayField,HiddenName

  1. #1

    Default [Solved] ComboBox valueField,displayField,HiddenName

    Hello,

    I have problem with my new script, i have tryd the HiddenName stuff, nothing works, always the wrong value.

    I'm getting the values are like (ID,Name) Combobox should post the ID and show the Name.

    Loader:
    PHP Code:
      var mudelReader = new Ext.data.JsonReader({
                    
    id'mudelid',
                    
    name:'mudelid'
                
    }, [ 'sid''mudelnimi']);

    var 
    mudels = new Ext.data.Store({
            
    proxy: new Ext.data.HttpProxy({
                
    url'json/mudelid.php'
            
    }),
            
    readermudelReader,
            
    remoteSortfalse
        
    });

    mudels.load(); 
    ComboBox Field:
    PHP Code:
      mudelField = new Ext.form.ComboBox({
        
    id:'mudels',
        
    fieldLabel'Mudel',
        
    allowBlankfalse,
        
    typeAheadtrue,
        
    triggerAction'all',
        
    store:mudels,
         
    mode'local',
         
    displayField'mudelnimi',
         
    hiddenName:'mudelnimi',
         
    valueField'sid',
         
    anchor:'95%'
        
    }); 
    I have more than 1 combobox in the code, i have set different ids,name.

    For example i use car models like (Audi A6), ID: 9 Name: A6, it most display 9 but it display A6

    Can somebody help me with that? I'm trying to find the way more than 4 hours for now.

  2. #2
    Sencha User Eugen_'s Avatar
    Join Date
    Feb 2010
    Posts
    106

    Default

    Hi, Nokia555

    maybe

    Code:
    
    var mudelReader = new Ext.data.JsonReader({
                    id: 'sid',
                    name:'mudelid'
                }, [ 'sid', 'mudelnimi']);
    
    var mudels = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                url: 'json/mudelid.php'
            }),
            reader: mudelReader,
            remoteSort: false
        });
    
    mudels.load(); 
    
    
      mudelField = new Ext.form.ComboBox({
        id:'mudels',
        fieldLabel: 'Mudel',
        allowBlank: false,
        typeAhead: true,
        triggerAction: 'all',
        store:mudels,
         mode: 'remote',
         displayField: 'mudelnimi',
         hiddenName:'sid',
         valueField: 'sid',
         anchor:'95%'
        }); 
    

  3. #3

    Default

    It didn't help
    When i select A6 from combobox then its Ok, says the ID, but when i set some other field active and press save again, then its already A6

    PHP Code:
        function isVaruosaValid(){
          return(
    nimiField.isValid() && hindField.isValid() && catField.isValid() && markField.isValid() && mudelField.isValid() && lisainfoField.isValid() && mudeltField.isValid());
      }

      function 
    resetVaruosaForm(){
        
    nimiField.setValue('');
        
    hindField.setValue('');
        
    mudelField.setValue('');
        
    lisainfoField.setValue('');
        
    mudeltField.setValue('');
      }

      var 
    mudelReader = new Ext.data.JsonReader({
                    
    id'sid',
                    
    name:'mudelid'
                
    }, [ 'sid''mudelnimi']);

    var 
    mudels = new Ext.data.Store({
            
    proxy: new Ext.data.HttpProxy({
                
    url'json/mudelid.php'
            
    }),
            
    readermudelReader,
            
    remoteSortfalse
        
    });

      
    nimiField = new Ext.form.TextField({
        
    id'nimi',
        
    fieldLabel'Nimi',
        
    maxLength20,
        
    allowBlankfalse,
        
    anchor '95%'
          
    });

      
    hindField = new Ext.form.TextField({
        
    id'hind',
        
    fieldLabel'Hind',
        
    maxLength20,
        
    allowBlankfalse,
        
    anchor '95%'
          
    });

      
    catField = new Ext.form.ComboBox({
        
    id:'cats',
        
    name:'cats',
        
    fieldLabel'Kategooria',
        
    allowBlankfalse,
        
    typeAheadtrue,
        
    triggerAction'all',
        
    store:cats,
        
    mode'remote',
         
    displayField'nimi',
         
    valueField'id',
         
    anchor:'95%'
        
    });

      
    markField = new Ext.form.ComboBox({
        
    id:'mark',
        
    name:'mark',
        
    fieldLabel'Mark',
        
    allowBlankfalse,
        
    typeAheadtrue,
        
    triggerAction'all',
        
    store:margid,
         
    mode'remote',
        
    hiddenName:'nimi',
         
    displayField'nimi',
         
    valueField'mid',
         
    anchor:'95%'
        
    });

          
    markField.on('select', function(comborecordindex) {
        
    mudels.reload({params: {
            
    smarkmarkField.getValue()
                }})
      });

      
    mudelField = new Ext.form.ComboBox({
        
    id:'mudels',
        
    fieldLabel'Mudel',
        
    allowBlankfalse,
        
    typeAheadtrue,
        
    triggerAction'all',
        
    store:mudels,
         
    mode'remote',
         
    displayField'mudelnimi',
         
    hiddenName:'mudelnimi',
         
    valueField'sid',
         
    anchor:'95%'
        
    });

      
    mudeltField = new Ext.form.TextField({
        
    id'mudelt',
        
    fieldLabel'Mudel Tpsustus',
        
    maxLength20,
        
    allowBlanktrue,
        
    anchor '95%'
          
    });


      
    lisainfoField = new Ext.form.TextField({
        
    id'lisainfo',
        
    fieldLabel'Lisainfo',
        
    maxLength20,
        
    allowBlanktrue,
        
    anchor '95%'
          
    });


      
    VaruosaForm = new Ext.FormPanel({
            
    labelAlign'top',
            
    bodyStyle:'padding:5px',
            
    width600,
            
    items: [{
                
    layout:'column',
                
    border:false,
                
    items:[{
                    
    columnWidth:0.5,
                    
    layout'form',
                    
    border:false,
                    
    items: [nimiFieldhindFieldcatField]
                },{
                    
    columnWidth:0.5,
                    
    layout'form',
                    
    border:false,
                    
    items: [markFieldmudelFieldmudeltField,lisainfoField]
                }]
            }],
        
    buttons: [{
          
    text'Lisa ja sulge',
          
    iconCls'add',
          
    handlerlisavaruosa2
        
    },{
          
    text'Katkesta',
          
    handler: function(){
            
    // because of the global vars, we can only instantiate one window... so let's just hide it.
            
    VaruosaCreateWindow.hide();
          }
        }]
        });

        function 
    lisavaruosa2() {
            
    alert(markField.getValue() + ' ' mudelField.getValue());
        }


        
    VaruosaCreateWindow= new Ext.Window({
          
    id'VaruosaCreateWindow',
          
    title'Uue varuosa lisamine',
          
    closable:true,
          
    width610,
          
    height300,
          
    plain:true,
          
    layout'fit',
          
    itemsVaruosaForm
        
    });


      function 
    lisavaruosa(){
         if(
    isVaruosaValid()){
          
    Ext.Ajax.request({   
            
    waitMsg'Please wait...',
            
    url'database.php',
            
    params: {
              
    task"UUSVARUOSA",
              
    useridxidID,
              
    nimi:      nimiField.getValue(),
              
    hind:       hindField.getValue(),
              
    cat:       catField.getValue(),
              
    mark:  markField.getValue(),
              
    mudel:          mudelField.getValue(),
              
    lisainfo:          lisainfoField.getValue(),
              
    mudel_t2psustus:          mudeltField.getValue()
            }, 
            
    success: function(response){              
              var 
    result=eval(response.responseText);
              switch(
    result){
              case 
    1:
                
    Ext.MessageBox.alert('Creation OK','Uus toode on lisatud.');
                
    VaruosadDataStore.reload();
                
    VaruosaCreateWindow.hide();
                break;
              default:
                
    Ext.MessageBox.alert('Warning','Toote lisamisel tekkis probleem.');
                break;
              }        
            },
            
    failure: function(response){
              var 
    result=response.responseText;
              
    Ext.MessageBox.alert('error','could not connect to the database. retry later');         
            }                      
          });
        } else {
          
    Ext.MessageBox.alert('Warning''Your Form is not valid!');
        }
      }

       function 
    displayVaruosaWindow(){
         if(!
    VaruosaCreateWindow.isVisible()){
           
    resetVaruosaForm();
           
    VaruosaCreateWindow.show();
         } else {
           
    VaruosaCreateWindow.toFront();
         }
      } 

  4. #4
    Sencha User Eugen_'s Avatar
    Join Date
    Feb 2010
    Posts
    106

    Default

    Nokia555, see the example

    Code:
            var bFirstLoading = true;
            
            var storeClinic = new Ext.data.Store({
                url: '',
                autoLoad: true,
                reader: new Ext.data.XmlReader({
                    record: 'clinic',
                    id: 'clinic_id'
                }, [
                    {name: 'clinic_id', type: 'int'},
                    {name: 'clinic_title', type: 'string'}
                ]),
                listeners: {
                    'load': function(store, records, options) {
                        if (bFirstLoading) {
                            bFirstLoading = false;
                            /* I set current clinic_id here after first loading */
                            if (edit) {
                                comboClinic.setValue(record.get('clinic_id'));
                            }
                        }
                    }
                }
            });
            var comboClinic = new Ext.form.ComboBox({
                store: storeClinic,
                name: 'clinic_id',
                fieldLabel: 'Clinic',
                displayField: 'clinic_title',
                valueField: 'clinic_id',
                emptyText: 'Select ...',
                selectOnFocus: true,
                editable: false,
                triggerAction: 'all',
                mode: 'remote',
                forceSelection: true,
                listeners: {
                    'beforequery': function(qe) {
                        delete qe.combo.lastQuery;
                    }
                },
                anchor: '100%'
            });
    to get the id

    Code:
    comboClinic.getValue()
    to get the title

    Code:
        var record;
        for (var i = 0; i < storeClinic.getCount(); i++) {
            record = storeClinic.getAt(i);
            if (comboClinic.getValue() == record.get('clinic_id')) {
                alert(record.get('clinic_title'));
                break;
            }
        }

Posting Permissions

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