---
title: "combobox--4"
author: "youyang_java"
date: "2014-06-17T11:17:55Z"
tags: []
categories: ["Web前端"]
slug: "combobox-4"
draft: false
lastmod: "2014-06-16T10:38:26Z"
id: 2080472
url: "https://youyang-java.iteye.com/blog/2080472"
---

![](http://dl2.iteye.com/upload/attachment/0098/1396/653e14ce-4e26-3b6f-bb4e-691824502d24.png)  
 &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;  
&lt;html&gt;  
  &lt;head&gt;  
   
    &lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;  
    &lt;meta http-equiv="description" content="this is my page"&gt;  
    &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;  
     
    &lt;!-- easyui的样式 --&gt;  
    &lt;link rel="stylesheet" type="text/css" href="../jslib/jquery-easyui-1.3.1/themes/default/easyui.css"&gt;  
    &lt;!-- 小图标的样式 --&gt;  
    &lt;link rel="stylesheet" type="text/css" href="../jslib/jquery-easyui-1.3.1/themes/icon.css"&gt;  
     
    &lt;script type="text/javascript" src="../jslib/jquery-easyui-1.3.1/jquery-1.8.0.min.js"&gt;&lt;/script&gt;  
    &lt;script type="text/javascript" src="../jslib/jquery-easyui-1.3.1/jquery.easyui.min.js"&gt;&lt;/script&gt;  
    &lt;script type="text/javascript" src="../jslib/jquery-easyui-1.3.1/locale/easyui-lang-zh\_CN.js"&gt;&lt;/script&gt;  
   
 &lt;script type="text/javascript"&gt;  
   
  var d = [{    
        "id":1,    
        "text":"text1"   
    },{    
        "id":2,    
        "text":"text2"   
    },{    
        "id":3,    
        "text":"text3",    
        "selected":true   
    },{    
        "id":4,    
        "text":"Text4"   
    },{    
        "id":5,    
        "text":"text5"   
    }] ;  
    
    
  $(function(){  
   $('#cc').combobox({    
       data:d,    
       valueField:'id',    
       textField:'text',  
       //本地数据过滤  
       filter: function(q, row){  
        //找到匹配的字母  
     var opts = $(this).combobox('options');  
     return row\[opts.textField].toUpperCase().indexOf(q.toUpperCase()) &gt;= 0;  
    },  
    formatter: function(row){  
     var opts = $(this).combobox('options');  
     return row\[opts.textField]+'xxxx';  
    }  
         
            
   });  
  });  
 &lt;/script&gt;  
   
  &lt;/head&gt;  
     
  &lt;body&gt;   
    &lt;input id="cc" /&gt;   
  &lt;/body&gt;  
&lt;/html&gt;