日期:2014-05-16  浏览次数:20710 次

extjs combobox如何向服务器传值
我是个combobox初学者我的代码如下
JScript code
Ext.require([
    'Ext.form.ComboBox',
    'Ext.tip.QuickTips',
    'Ext.data.*'
]);
Ext.onReady(function() {
    Ext.tip.QuickTips.init();
    // Define the model for a State
    Ext.regModel('State', {
        fields: [
            {type: 'string', name: 'xh'},
            {type: 'string', name: 'xm'}
        ]
       
    });

    // The data for all states
   
    // The data store holding the states; shared by each of the ComboBox examples below
//    var store = new Ext.data.Store({
//        model: 'State',
//        data: states
//    });

    var comboxStore = new Ext.data.Store({ 
         model: 'State',         
         proxy: { 
             type:'ajax', 
              actionMethods: {
             create : 'POST',
             read   : 'POST',
             update : 'POST',
             destroy: 'POST'},
             url: "http://localhost:8080/cjcx/servlet/Getcj?Method=GetAllxhxm" , 
             reader:'json'         
         }, 
             atuoLoad:false            
         } ); 
//    comboxStore.load();

    // ComboBox with a custom item template
    var simple = new Ext.form.ComboBox({
        fieldLabel: '请输入您的姓名',
        renderTo: 'simple',
        displayField: 'xm',   
        valueField: 'name', 
//        hiddenValue:'xh',
//        hiddenField:'xh',
       // hiddenName:'empUserNum',
        allowBlank : false, 
        width: 500,
        labelWidth: 130,
        hideTrigger:true,
//        typeAhead:true,//延时查询,与下面的参数配合
//        typeAheadDelay:250,//默认250
         blankText:'输入姓名查询成绩',
         emptyText:'输入姓名查询成绩', 
         listEmptyText:'请仔细核对姓名信息',
         minChars : 1,          
         store:  comboxStore,
         query:'remote',   
         queryParam : 'empUserNum', 
//         hiddernName : 'empUserNum',        
         getInnerTpl: function() {
            return '<div ext:qtip="{xh}"> {xm}</div>';
            
       }
    });
  
     ////// Collapsible code panels; ignore: /////

    Ext.select('pre.code').each(function(pre) {
        new Ext.form.FieldSet({
            contentEl: pre,
            renderTo: pre.parent(),
            title: 'View code for this example',
            collapsible: true,
            collapsed: true
        })
    });

});



请问我怎么才能通过一个按钮把选中学生姓名时对应的学号传送到服务器端啊

------解决方案--------------------
JScript code

userForm.form.doAction('submit', {
    url : 'user!saveUser.action',
    method : 'post',
    params : '',
    success: function(form, action) {
        if (action.result.message == "success")
        {
            Ext.Msg.alert("Information", "save success");
        } else
        {
            Ext.Msg.alert("Information", "save fail," + action.result.message);
        }                                       
    },
    failure: function(form, action) {        
         Ext.Msg.alert("Information", "save_fail," + action.result.message);
    }
});