jq插件

//54814002-25516950

//54814002-25516950

//54814002-25516950

//54814002-25516950

//54814002-25516950

 

13795211360 lj

15710126915  zyx

3310+339+261+325+205+294+199+74=

 

/**
 *
 */
Ext.require([
     'Ext.query.*',
     'Ext.grid.*',
     'Ext.data.*',
     'Ext.util.*',
     'Ext.state.*',
     'Ext.form.*'
 ]);

       
Ext.onReady(function() {
   
Ext.define('Book',{
    extend: 'Ext.data.Model',
    fields: [
        'Property',
        'Value 1',
        'Value 2'
    ]
});

Ext.tip.QuickTipManager.init();

// Define the model for a State
Ext.define('State', {
    extend: 'Ext.data.Model',
    fields: [
        {type: 'string', name: 'label'},
        {type: 'string', name: 'value'}
    ]
});

var states = [{"label":"abc", "value":"abc"}, {"label":"bcde","value":"bcde"}, {"label":"ace","value":"ace"}];

var statesStore = Ext.create('Ext.data.Store', {
    model: 'State',
    data: states
});

var combo = Ext.create('Ext.form.field.ComboBox', {
    fieldLabel: '<b>Subject</b>',
    renderTo: 'inputSubject',
    displayField: 'label',
    width: 300,
    labelWidth: 80,
    store: statesStore,
    queryMode: 'local',
    typeAhead: true,
    transform: 'inputSubject',
    forceSelection: true
});

combo.on('beforequery',function(e){
    var combo = e.combo;
    if(!e.forceAll){
        var value = e.query;
        combo.store.filterBy(function(record,id){
        var text = record.get(combo.displayField);
            return (text.indexOf(value)!=-1);
        }); 
        combo.expand(); 
        return false;
    } 
});

    var store = Ext.create('Ext.data.Store', {
        storeId:'simpsonsStore',
        fields:['name', 'email', 'phone'],
        data:{'items':[
            {"name":"Lisa", "email":"[email protected]", "phone":"555-111-1224"},
            {"name":"Bart", "email":"[email protected]", "phone":"555--222-1234"},
            {"name":"Homer", "email":"[email protected]", "phone":"555-222-1244"},                       
            {"name":"Marge", "email":"[email protected]", "phone":"555-222-1254"}           
        ]},
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
        },
        sorters: [{
            property: 'email',
            direction: 'ASC'
        }]
    });

    var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
        clicksToMoveEditor: 1,
        autoCancel: false
    });
   
    var grid = Ext.create('Ext.grid.Panel', {
        title: 'Content',
        store: Ext.data.StoreManager.lookup('simpsonsStore'),
        columns: [
//                       {  //header:    'Name',
               //dataIndex: 'name',
//                          flex:1
//                       },
            {  
                  name:     "name",
                  hidden:   false,
                  hideable: true,
                  header:   "Name",
                  editor: {
                     xtype:        "combo",
                     typeAhead:    true,
                     triggerAction:"all",
                     lazyRender:   true,
                     listClass:    "x-combo-list-small",
                     store:[
                        [ "0" , "Staff Account"  ], //the value at index 0 is
                                                    //assumed to be the combo value
                        [ "1" , "Admin Account" ],  //the value at index 1 is
                                                    //assumed to be the combo text
                        [ "2" , "Super Account" ]
                     ]
                  },
                  width:150
            },
            {  header:    'Email',
               dataIndex: 'email',
               flex:1,
                  editor: {
                          allowBlank: true
                  }
            },
            {  header:    'Phone',
               dataIndex: 'phone',
               flex:1,
                  editor: {
                          allowBlank: true
                  }
            }
        ],
        height: 300,
        width: 800,
        renderTo: 'content',
        tbar: [{
            itemId: 'saveTemplateBtn',
            text: '<b>Save Template</b>',
//                       iconCls: 'employee-add',
            handler : function() {
                rowEditing.cancelEdit();
                var store = grid.getStore();
                var count = store.getCount();
                if(count == 0)
                    Ext.MessageBox.alert('Warn', 'Please input parameters!');
                   
                for(var i=0; i<count; i++) {
                    var rowData = store.getAt(i).data;
                    var email = rowData.email;
                    var phone = rowData.phone;
                }
               
               
               
            }
        }, {
            itemId: 'publishBtn',
            text: '<b>Publish</b>',
//                       iconCls: 'employee-remove',
            handler: function() {
//               var sm = grid.getSelectionModel();
                  rowEditing.cancelEdit();
//                 store.remove(sm.getSelection());
//              sm.select(0);
                 
                  store = Ext.create('Ext.data.Store', {
                    storeId:'simpsonsStore',
                    fields:['name', 'email', 'phone'],
                    data:{'items':[
                        {"name":"a", "email":"[email protected]", "phone":"-1224"},
                        {"name":"b", "email":"[email protected]", "phone":"-1234"},
                        {"name":"c", "email":"[email protected]", "phone":"-1244"},                       
                        {"name":"d", "email":"[email protected]", "phone":"-1254"}             
                    ]},
                    proxy: {
                        type: 'memory',
                        reader: {
                            type: 'json',
                            root: 'items'
                        }
                    },
                    sorters: [{
                        property: 'email',
                        direction: 'ASC'
                    }]
                });
                 
                  store.load();
               
            },
            disabled: false
        }, {
            itemId: 'addRow',
            text: '<b>Add Row</b>',
//                       iconCls: 'employee-remove',
            handler: function() {
                rowEditing.cancelEdit();
                var r = Ext.ModelManager.create({
                    name: 'Ch',
                    email: '[email protected]',
                    phone: '123456'
                }, 'Book');

                store.insert(0, r);
                rowEditing.startEdit(0, 0);
            },
            disabled: false
        }, {
            itemId: 'deleteRow',
            text: '<b>Delete Row</b>',
//                       iconCls: 'employee-remove',
            handler: function() {
                if(grid.getStore().getCount() == 0) return;
                   var sm = grid.getSelectionModel();
                  rowEditing.cancelEdit();
                 store.remove(sm.getSelection());
                  sm.select(0);
            },
            disabled: false
        }],
        plugins: [rowEditing]
    });
   
});

你可能感兴趣的:(插件)