Extjs之旅-combox之本地加载数据
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="shared/example.css" />
<script type="text/javascript" src="js/ext/ext-all.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
Ext.onReady(function(){
//创建数据模型
Ext.regModel('postInfo',{
fields:[{name:'province'},{name:'post'}]
});
//定义组合框中显示的数据源
var postStore = Ext.create('Ext.data.Store',{
model:'postInfo',
data:[
{province:'北京',post:'100000'},
{province:'通县',post:'101100'},
{province:'昌平',post:'102200'},
{province:'大兴',post:'102600'},
{province:'密云',post:'101500'},
{province:'延庆',post:'102100'},
{province:'顺义',post:'101300'}
]
});
//创建表单
Ext.create('Ext.form.Panel',{
title:'Ext.form.ComboBox本地数据源演示',
renderTo:Ext.getBody(),
bodyPadding:5,
frame:true,
height:100,
width:270,
defaults:{
labelSeparator:': ',
labelWidth:70,
width:200,
labelAlign:'left'
},
items:[{
xtype:'combo',
listConfig:{
emptyText:'未找到匹配值',
maxHeight:60
},
name:'post',
fieldLabel:'邮政编码',
triggerAction:'all',//单击按钮显示全部数据
store:postStore,
displayField:'province',//定义要显示的字段
valueField:'post',
queryMode:'local',//本地模式
forceSelection:true,//要求输入值必须在列表中存在
typeAhead:true,//允许自动选择匹配的剩余部分文本
value:'102600'//默认值
}]
});
});
</script>
</head>
<body>
<div id="form"></div>
</body>
</html> 相关推荐
qiupu 2020-11-04
jiedinghui 2020-10-25
Ladyseven 2020-10-22
hellowzm 2020-10-12
zuncle 2020-09-28
Ladyseven 2020-09-11
jiedinghui 2020-09-07
xiaohuli 2020-09-02
葉無聞 2020-09-01
impress 2020-08-26
ThikHome 2020-08-24
nicepainkiller 2020-08-20
hellowzm 2020-08-18