Extjs 3.4 Combo - 如何使select函数触发

时间:2015-08-05 14:48:49

标签: javascript extjs extjs3

ComboCode

var applicationStore = new Ext.data.Store({
    autoLoad    : true,
    url         : 'index.php',
    method      : 'post',
    baseParams  : {action : 'getListApplication'},
    idProperty  : 'id',
    sortInfo    : {field : 'APPLICATION_REF', direction : 'ASC'},
    reader      : new Ext.data.JsonReader({
        fields  : [
            {name: 'id',                        type: 'integer'},
            {name: 'APPLICATION_ACTION',        type: 'STRING'},
            {name: 'APPLICATION_ID',            type: 'integer'},
            {name: 'APPLICATION_REF',           type: 'string'},
            {name: 'APPLICATION_LABEL',         type: 'string'}
        ]
    })
});

var formUserIDPannel = new Ext.form.ComboBox({
    /*id : 'formUserIDPannel',
    title : 'Liste des Applications',*/
    renderTo : 'principalContainer',
    /*frame : true,
    padding : 0,
    labelWidth : 95,*/
    //items : [ {
    id : 'combo',
    xtype           : 'combo',
    fieldLabel      : 'Application',
    emptyText       : 'Selectionnez une application',
    anchor          : '97%',
    style           : 'text-align:center;',
    labelStyle      : 'font-weight:bold;',
    labelSeparator  : '',
    store           : applicationStore,
    tpl             : '<tpl for="."><div ext:qtip="{APPLICATION_LABEL}" class="x-combo-list-item">{APPLICATION_REF}</div></tpl>',
    displayField    : 'APPLICATION_REF',
    valueField      : 'APPLICATION_LABEL',
    mode            : 'local',
    triggerAction   : 'all',
    hiddenName : 'APPLICATION_ID',
    hiddenValue : 'APPLICATION_ID',
    selectODFocus:  :true,
    editable        : false ,
    listeners       : {
        'select': function(combo, record, index) {
        }
   // }]

    }
});




/*var formUserIDPannel = new Ext.FormPanel({
    id : 'formUserIDPannel',
    title : 'Liste des Applications',
    renderTo : 'principalContainer',
    frame : true,
    padding : 0,
    labelWidth : 95,
    items : [ {
        xtype : 'combo',
        id : 'CAD_ID_COMBO',
        name : 'CAD_ID_COMBO',
        fieldLabel : 'Application',
        labelStyle : 'font-weight:bold',
        anchor : '80%',
        labelSeparator : '',
        emptyText : 'Selectionnez une application',
        store : new Ext.data.ArrayStore({
            id : 0,
            fields : [ 'id', 'value' ],
            data : [ [ 1, 'TMS' ], [ 2, 'SOFT' ], [ 3, 'Autres' ], ]
        }),
        displayField : 'value',
        valueField : 'id',
        hiddenName : 'APPLICATION_ID',
        hiddenValue : 'APPLICATION_ID',
        mode : 'local',
        triggerAction : 'all',
        editable : true
    } ]
});*/

var application = Ext.data.Record.create([
    {name: 'id',                        type: 'integer'},
    {name: 'APPLICATION_ACTION',        type: 'string'},
    {name: 'APPLICATION_ID',            type: 'integer'},
    {name: 'APPLICATION_REF',           type: 'string'},
    {name: 'CADENCE',                   type: 'integer'},
    {name: 'PRICE',                     type: 'integer'}

]);

var gridStore = new Ext.data.GroupingStore({
    reader      : new Ext.data.JsonReader({fields: application}),
    autoLoad    : true,
    url         : 'index.php',
    method      : 'post',
    baseParams  : {action : 'getListApplication'},
    sortInfo    : {field: 'APPLICATION_REF', direction: 'ASC'}
});

var editor = new Ext.ux.grid.RowEditor({saveText : 'Sauvegarder', cancelText : 'Annuler'});

editor.on('canceledit', function(roweditor, cancel){
    if(cancel)
    {
        if(grid.getSelectionModel().getSelected().get('APPLICATION_ACTION') == 'add')
        {
            gridStore.remove(grid.getSelectionModel().getSelected());
        }
    }
    //Ext.getCmp('buttonAddApplication').setDisabled(false);
});

editor.on('validateedit', function(roweditor, change, record, rowIndex){
    var setRecord = new Array();
    if(record.get('APPLICATION_ACTION') == 'add')
    {
        setRecord = change;
    }
    else if(record.get('APPLICATION_ACTION') == 'update')
    {

        for(i in change)
        {
            setRecord.push({'key' :  i, 'value' : change[i]});
        }
    }

    sendAjax({
        url             : 'index.php',
        showBusy        : false,
        params          : {action : 'actionCadence', data : Ext.encode({actionBDD : record.get('APPLICATION_ACTION'), 'APPLICATION_ID' : record.get('APPLICATION_ID'), where : [{'key' : 'APPLICATION_ID', 'val':record.get('APPLICATION_ID')}], set : setRecord})},
        method          : 'post',
        renderVar       : 'responseJSON',
        successCallback : {
            functionName :  function() {
                //Ext.getCmp('buttonAddApplication').setDisabled(false);
                Ext.alert.msg(responseJSON.title, responseJSON.message);

                if(responseJSON.success == true)
                {
                    if(Ext.getCmp('gridApplication').getSelectionModel().getSelected().get('APPLICATION_ACTION') == 'add')
                    {
                        if(Ext.isDefined(responseJSON.APPLICATION_ID))
                        {
                            Ext.getCmp('gridApplication').getSelectionModel().getSelected().set('APPLICATION_ID', responseJSON.APPLICATION_ID);
                        }
                        Ext.getCmp('gridApplication').getSelectionModel().getSelected().set('APPLICATION_ACTION', 'update');
                    }
                }
                else
                {
                    if(Ext.getCmp('gridApplication').getSelectionModel().getSelected().get('APPLICATION_ACTION') == 'add')
                    {
                        Ext.getCmp('gridApplication').getStore().remove(Ext.getCmp('gridApplication').getSelectionModel().getSelected());
                    }
                    editor.stopEditing();
                }

            }
        }
    });
});

var reseizer = new Ext.ux.PanelResizer({minHeight: 250, maxHeight: 800});

var filters = new Ext.grid.GridFilters({
    local  : true,
  filters:[
    {type: 'string',  dataIndex: 'APPLICATION_REF'}
          ]
});

var grid = new Ext.grid.GridPanel({
    id                  : 'gridApplication',
    store               : gridStore,
    width               : 500,
    height              : 600,
    selModel            : new Ext.grid.RowSelectionModel({singleSelect : true}),
    title               : 'Détails des Applications',
    renderTo            : 'gridContainer',
    autoHeight          : false,
    stripeRows          : true,
    frame               : true,
    loadMask            : true,
    enableColumnMove    : false,
    enableDragDrop      : false,
    autoExpandColumn    : 'APPLICATION_REF',
    plugins             : [editor, reseizer,filters],
    view                : new Ext.grid.GroupingView({markDirty: false}),
    //plugins               :[filters, new Ext.ux.grid.GroupSummary()],
    columns             : [ {
                                id          : 'APPLICATION_REF',
                                header      : 'Tache/Opératrion ',
                                dataIndex   : 'APPLICATION_REF',
                                width       : 200,
                                sortable    : true,
                              },{
                                header      : 'Cadence',
                                dataIndex   : 'CADENCE',
                                width       : 150,
                                sortable    : true,
                                editor      : {
                                                xtype       : 'textfield',
                                                allowBlank  : true
                                              }
                            },{
                                header      : 'Prix',
                                dataIndex   : 'PRICE',
                                width       : 150,
                                sortable    : true,
                                editor      : {
                                                xtype       : 'textfield',
                                                allowBlank  : true
                                              }
                            }


                            ]
});

1 个答案:

答案 0 :(得分:0)

这是来自ExtJS 4.2
尝试不带引号的选择

 before(function(done) {
  mongoose.connection.collections['users'].drop(function(err) {
    mongoose.connection.collections['users'].insert(user, done);
  });
//   User.remove({}).exec(function() {
//     User.create(user, done);
//   });
});