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


    后台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,希望可以帮到需要的人

  • 相关阅读:
    链表和递归
    Async and Await
    Linux下如何对目录中的文件进行统计
    Linux系统添加自定义网卡并更改网卡接口
    运维实战:Linux系统扩展oracle数据库所在的分区
    在Linux命令行发送电子邮件附件的两种方法
    Centos7部署轻量级自动化运维工具pssh
    CentOS7中使用systemctl列出启动失败的服务
    AbstractQueuedSynchronizer详解(转)
    Oracle 11g数据导入到10g
  • 原文地址:https://www.cnblogs.com/duzjextjs/p/5392329.html
Copyright © 2020-2023  润新知