码迷,mamicode.com
首页 > Web开发 > 详细

extjs下拉框,多选,单选,动态传值

时间:2016-04-14 19:26:23      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

后台java代码

@RequestMapping(params = "command=adduser")
public void getUser(HttpServletResponse response) throws Exception{
JSONObject result1 = new JSONObject();
JSONArray rows1 = new JSONArray();
String search ="1=1";
List<Inducedcause> list = inducedcauseService.getInducedcauseList(search);
JSONObject ux = null;
for(Inducedcause uc:list){
ux= new JSONObject();
ux.put("id", uc.getId());
ux.put("reason", uc.getReason());
rows1.put(ux);
}
result1.put("results1", rows1);
// result.put("totalCount", list.size());
response.getWriter().write(result1.toString());
}

前台extjs代码

var comstore1 = new Ext.data.Store(
{proxy: new Ext.data.HttpProxy({url: ‘${pageContext.request.contextPath}/treatmentrecord/treatmentrecord.page?command=adduser‘}), 
//读取json
reader: new Ext.data.JsonReader({
root: ‘results1‘,
remoteSort: true,
fields: [‘id‘,‘reason‘]})
});

{
xtype:‘lovcombo‘,
fieldLabel: ‘诱发原因‘,
id: ‘inducedcause-id‘,
name: ‘inducedcause‘,
displayField : ‘reason‘,
valueField : ‘id‘,
hiddenName : ‘id‘,
mode : ‘local‘,
editable:false,
loadingText : ‘加载中...‘,
store : comstore1,
value:‘<%=realname%>‘,
emptyText:‘请选择原因‘,
triggerAction : ‘all‘,
maxLength : 100,
multiSelect:true,
anchor:‘100%‘
},

要实现多选下拉框要引入两个JS类库

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/ext/examples/ux/css/Ext.ux.form.LovCombo.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/ext/examples/ux/Ext.ux.form.LovCombo.js"></script>

否则为单选下拉框,数据是动态的

初学extjs,希望可以帮到需要的人

extjs下拉框,多选,单选,动态传值

标签:

原文地址:http://www.cnblogs.com/duzjextjs/p/5392329.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!