标签:
后台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,希望可以帮到需要的人
标签:
原文地址:http://www.cnblogs.com/duzjextjs/p/5392329.html