Extjs网格单元格编辑器与组合

时间:2016-11-25 09:19:22

标签: extjs

我有一个带3个组合框的网格面板,但是当我在一个组合框中选择一个值时,所有其他组合框都会被清除。为什么会这样? 这是我的代码。有人可以帮忙吗?

 Ext.define('XNARUM.view.fieldgroup.mapGrid',{
    extend:'Ext.grid.Panel',
    xtype: 'fieldgrp-mapgrid',
    region:'center',
    autoscroll: true,
    stripeRows: true,
    layout: 'fit',
    loadMask: true,


requires: [
    'Ext.form.field.ComboBox', 
    'XNARUM.store.fieldgroup.fieldGridStore'
],

selType: 'cellmodel',
plugins: [
    Ext.create('Ext.grid.plugin.CellEditing', {
        clicksToEdit: 2,
         listeners: {
            beforeedit: function(e, editor){
                    if(editStatus== 0){
                          return false;
                    }
            }
        }
    })
],
defaults: {
  flex: 1
},
store:'fieldgroup.mapGridStore',

dockedItems: [{
  xtype: 'toolbar',
  items: [{
    xtype: 'form',
    items: [{
       xtype:'label',
       text : 'Fieldgroup mapping info'
  }]
  }, '->',{

    xtype: 'textfield',
    name:'index',
    width :30,
    hidden :true
  },{
    xtype: 'button',
    iconCls: 'fa fa-plus-circle',
    action:'add',
    tooltip:'add',
    hidden :true
  },{
    xtype: 'button',
    iconCls: 'fa fa-minus-circle',
    action:'delete',
    tooltip:'delete',
    hidden :true
  }]
}],
viewConfig: {
plugins: {
    ptype: 'gridviewdragdrop'
},

listeners: {
    beforedrop: function (node, data, dropRec, dropPosition) {
        //Get the sequence number of the record dropped on
        var recordSequence = dropRec.get('sequence');
        //The record being dragged
        var dragRecord = data.records[0];
        //Get the sequence number of the drag record currently
        var dragRecordCurrSequence = data.records[0].get('sequence');

        //Calculate what the new sequence number should be for the dragged 
        //row based on where it is dropped.
        if (dropPosition == 'after' && recordSequence < dragRecordCurrSequence) {
            dragRecord.set('sequence', recordSequence + 1);
        } else if (dropPosition == 'before' && recordSequence > dragRecordCurrSequence) {
            dragRecord.set('sequence', recordSequence - 1);
        } else {
            dragRecord.set('sequence', recordSequence);
        }

        //This delays the load of the grid data until after the sync
        //This is not an ideal solution and an appropriate event listener would be better
       /* var delayedLoad = new Ext.util.DelayedTask(function () {
            data.view.store.load();
        })
        delayedLoad.delay(250);*/
    }
}
},

columns: [{
        xtype: 'rownumberer'
  },{
        text: 'Field id',
        dataIndex: 'fieldId',
        flex: 1
  },{
        text: 'Field name',
        dataIndex: 'fieldName',
        flex: 2
  },{
        text: 'Length',
        dataIndex: 'fieldLength',
        flex:1
  },{
        text: 'Offset',
        dataIndex: 'fieldOffset',
        flex: 1
  },{
        text: 'Type',
        dataIndex: 'fieldType',
        flex: 1,

        renderer: function(val, meta, record){
          if(val=="C"){
              return  "Character";
          }
          else if(val=="N"){
              return  "Number";
          }
          else if(val=="D"){
              return  "Date";
          }
          else if(val=="B"){
              return  "Binary";
          }
          else{
              return  "NString";
          }
        }
  },{
        text: 'Format',
        dataIndex: 'fieldFormat',
        flex: 1
  },{
        text: 'Filler',
        dataIndex: 'filler',
        flex: 1,
        renderer: function(val, meta, record) {
              return val;             
        }
  },{
        text: 'Align',
        dataIndex: 'alignType',
        flex: 1,
        renderer: function(val, meta, record) {

              if(val=="L"){
                  return  "Left";
              }
              else{

                  return  "Right";
              }             
        }
  },{
        text: 'In/Out',
        dataIndex: 'inOutType',
        flex: 1,
        editor: {
               xtype: 'combo',
               name: 'inout',
               displayField: 'name',
               valueField: 'inOutType',
               fields: ['inOutType', 'name'],
                 triggerAction:'all',
                emptyText:'Account Type',
                queryMode:'local',
               store:{
               data : [
                    {"inOutType":"I", "name":"IN"},
                    {"inOutType":"O", "name":"OUT"},
                    {"inOutType":"B", "name":"IN/OUT"}
                  ]
               },
               value:'I',
               editable :false
        },
        renderer: function (val, meta, records) {
            if (this.editingPlugin.editing == true) {
                var combo = this.columns[9].getEditor();

                var record = combo.findRecord(combo.valueField, val);
                return record ? record.get(combo.displayField) : combo.valueNotFoundText;
            } else {                     

                if(val=="I"){
                    return  "In";
                }
                else if(val=="O"){

                    return  "OUT";
                }
                else{
                    return  "IN/OUT";
                }
            }
        }
  },{
        text: 'Is length field?',
        dataIndex: 'lengthFieldType',
        flex: 1,
        editor: {
               xtype: 'combo',
               name: 'inout',
               displayField: 'name',
               valueField: 'value',
               fields: ['value', 'name'],
                triggerAction:'all',
                emptyText:'Account Type',
                queryMode:'local',
               store:{
               data : [
                    {"value":"N", "name":"Normal field"},
                    {"value":"R", "name":"Detail report count"},
                    {"value":"F", "name":"FieldGroup length"},
                    {"value":"P", "name":"Partial Length"},
                    {"value":"T", "name":"Whole Length"}
                  ]
               },
               value:'N',
               editable :false
        },
        renderer: function (val, meta, records) {
            if (this.editingPlugin.editing == true) {
                var combo = this.columns[10].getEditor();

                var record = combo.findRecord(combo.valueField, val);
                return record ? record.get(combo.displayField) : combo.valueNotFoundText;
            } else {

                if(val=="N"){
                    return  "Normal field";
                }
                else if(val=="R"){

                    return  "Detail report count";
                }
                else if(val=="F"){

                    return  "FieldGroup length";
                }
                else if(val=="P"){

                    return  "Partial Length";
                }
                else{
                    return  "Whole Length";
                }
            }
        }
  },{
        text: 'value',
        dataIndex: 'valueDifference',
        flex: 1,
        editor: {
               xtype: 'textfield',
               name: 'value'
        },
        renderer: function (value, meta, records) {
            if (this.editingPlugin.editing == true) {
                var combo = this.columns[11].getEditor();

                return combo.value;
            }
            else{

              return value;
            }                
        }

  },{
        text: ' Key',
        dataIndex: 'isKey',
        flex: 1,
        editor: {
               xtype: 'combo',
               name: 'inout',
               displayField: 'name',
               valueField: 'value',
               fields: ['value', 'name'],
                 triggerAction:'all',
                emptyText:'Account Type',
                queryMode:'local',
               store:{
               data : [
                    {"value":"Y", "name":"Yes"},
                    {"value":"N", "name":"No"}
               ]

               },

               value:'N',
               editable :false
        },
        renderer: function (value, meta, records) {
            if (this.editingPlugin.editing == true) {
                var combo = this.columns[12].getEditor();

                var record = combo.findRecord(combo.valueField, value);
                return record ? record.get(combo.displayField) : combo.valueNotFoundText;
            } else {
               var val = value;

                if(val=="N"){
                    return  "No";
                }
                else {

                    return  "Yes";
                }
            }
        }
  },{
        text: 'Null',
        dataIndex: 'isNull',
        flex: 1,
        editor: {
               xtype: 'combo',
               name: 'inout',
               displayField: 'name',
               valueField: 'value',
               fields: ['value', 'name'],
                 triggerAction:'all',
                emptyText:'Account Type',
                queryMode:'local',
               store:{
               data : [
                    {"value":"Y", "name":"Yes"},
                    {"value":"N", "name":"No"}
               ]

               },
               value:'N',
               editable :false
        },
        renderer: function(value, meta, record) {
            if (this.editingPlugin.editing == true) {
                var combo = this.columns[13].getEditor();

                var record = combo.findRecord(combo.valueField, value);
                return record ? record.get(combo.displayField) : combo.valueNotFoundText;
            } else {
                var val = value;

                if(val=="N"){
                    return  "No";
                }
                else {

                    return  "Yes";
                }
            }
        }
  },{
        text: 'SQL function',
        dataIndex: 'isSqlFunction',
        flex: 1,
        editor: {
               xtype: 'combo',
               name: 'inout',
               displayField: 'name',
               valueField: 'value',
               fields: ['value', 'name'],
                 triggerAction:'all',
                emptyText:'Account Type',
                queryMode:'local',
               store:{
               data : [
                    {"value":"Y", "name":"Yes"},
                    {"value":"N", "name":"No"}
               ]

               },
               value:'N',
               editable :false
        },
        renderer: function(value, meta, record) {
            if (this.editingPlugin.editing == true) {
                var combo = this.columns[14].getEditor();

                var record = combo.findRecord(combo.valueField, value);
                return record ? record.get(combo.displayField) : combo.valueNotFoundText;
            } else {
                var val = value;

                if(val=="N"){
                    return  "No";
                }
                else {

                    return  "Yes";
                }
            }
        }
  },{
        text: 'Validation condition',
        dataIndex: 'fieldValidates',
        flex: 1
  }]  

});

0 个答案:

没有答案