easyui combobox动态默认选项设置

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
   <!-- 引入JQuery -->
  <script type="text/javascript" src="../JQuery-EasyUI-1.5.1/jquery.min.js"></script>
  <!-- 引入EasyUI -->
  <script type="text/javascript" src="../JQuery-EasyUI-1.5.1/jquery.easyui.min.js"></script>
  <!-- 引入EasyUI的中文国际化js,让EasyUI支持中文 -->
  <script type="text/javascript" src="../JQuery-EasyUI-1.5.1/locale/easyui-lang-zh_CN.js"></script>
  <!-- 引入EasyUI的样式文件-->
  <link rel="stylesheet" href="../JQuery-EasyUI-1.5.1/themes/default/easyui.css" type="text/css"/>
  <!-- 引入EasyUI的图标样式文件-->
  <link rel="stylesheet" href="../JQuery-EasyUI-1.5.1/themes/icon.css" type="text/css"/>
 
</head>
<body>
   <table id="dg" title="My Users" class="easyui-datagrid"
    style="width: 550px; height: 250px" 
    toolbar="#toolbar" rownumbers="true" fitColumns="true"
    singleSelect="true">
    <thead>
        <tr>
            <th field="firstname" width="50">First Name</th>
            <th field="lastname" width="50">Last Name</th>
            <th field="phone" width="50">Phone</th>
            <th field="email" width="50">Email</th>
        </tr>
    </thead>
</table>
<div id="toolbar">
    <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New User</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">Edit User</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">Remove User</a>
</div>
   
 <div>
     <select id="cc" class="easyui-combobox" name="dept" style="width:200px;">
     </select>
 </div> 
  <script type="text/javascript">
       var sq=2;
       $('#cc').combobox({
           data:[{text:'AAA',value:'0',selected:true},
                 {text:'BBB',value:'1'},
                 {text:'CCC',value:'2'},
                 {text:'DDD',value:'3'}],
onLoadSuccess:function(){
$(this).combobox('select',sq);
} });
</script> </body> </html>

 

posted @ 2017-06-03 10:20  conserdao  阅读(1278)  评论(0编辑  收藏  举报