2015-04-06 50 views

回答

0
Combobox = Ext.extend(Ext.form.ComboBox, { 
    allowBlank: false, 
    autoSelect: false, 
    baseParams: {}, 
    cls: "remote-server-finder", 
    displayField: 'name', 
    emptyText: "", 
    forceSelection: false, 
    itemSelector: 'div.remote-server-finder-item', 
    minChars: 0, 
    pageSize: 10, 
    queryDelay: 10, 
    store: null, 
    triggerAction: 'all', 
    typeAhead: true, 
    valueField: 'id', 
    minListWidth: 235, 
    maxHeight: 400, 
    /** 
    * Setup the data store and template for the finder. 
    */ 
    initComponent: function() { 
    this.blankText = helpsys.locale.javascript.field_required; 
    this.loadingText = helpsys.locale.common.searching; 
    this.listEmptyText = helpsys.locale.javascript.no_matching_record; 
    this.store = new Ext.data.JsonStore({ 
     baseParams: this.baseParams, 
     fields: [ 
     { 
      name: 'id' 
     }, 
     { 
      name: 'name' 
     }, 
     { 
      name: 'description' 
     }, 
     { 
      name: 'type' 
     } 
     ], 
     idProperty: 'id', 
     proxy: new Ext.data.HttpProxy({ 
     url: this.url, 
     method: 'GET', 
     listeners:{ 
      beforeload:{ 
       scope:this, 
       fn:function(dp, params){ 
        if(dp.activeRequest['read']){ 
         dp.activeRequest['read'].conn.abort(); 
        } 
       } 
      } 
     } 
     }), 
     root: 'items', 
     totalProperty: "totalResultsAvailable" 
    }); 

    this.tpl = new Ext.XTemplate('<tpl for="."><div class="remote-server-finder-item finder-item x-combo-list-item">', 
     '<div class="remote_server_finder_text finder_text">', '<h2 class="name">{name}</h2>', '<p class="description">{description}</p>', '</div>', '</div></tpl>'); 
    ); 
    }