关于ExtJS必输框,多选项

必填项:
//页面内传值用ID,和后台联系用name
<div class="col-xs-4">
                    <div class="form-group">
                        <label class="col-xs-4 control-label no-padding-right">主体<font class="red">*</font></label>
                        <div class="col-xs-6">                            
                            <select class="form-control" id="crmEntid1" name="crmEntid" title="crm_entid">
                            <!-- <option value="">----请选择----</option> -->
                        </select>
                        </div>
                    </div>
                    </div>
 
if(!$("[name='crmEntid']").val()){
                        Ext.Msg.alert('消息提示', '请选择主体.');
                        return false;
                    }
多选项:
<div class="col-xs-11"> <!-- 定长 -->
                    <div class="form-group">
 
                        <div class="col-xs-12">
                            <div class="checkbox" >
                              <label>
                                <input type="checkbox" value="-1" id="guiderType" name="guiderType">导购类型<font class="red">*</font>
                              </label>
                            </div>
                                <div id="guiderTypeList" background-color: inherit;">                                        10px;height:40px;overflow:auto;"> <!-- 定高,可滚动 -->
                            </div>
                        </div>
                    </div>                    
                </div>
 
 
// 获取导购类型(下拉单值)
        function getGuiderTypeBySetsOfbookId() {
    //定义变量,下拉值是动态查询的,这里是查询参数
            //var queryData = "{'itemClassLevl' : '2'}"; //商品大类item class level = 2
 
            Ext.Ajax.request({
        //调用后台方法
                url : '<%=request.getContextPath() %>/employee/allEmployeeManage.do?r_getGuiderType',
                //params : {'queryData' : queryData},
                method : 'POST',
                success : function(response, options) {
                    var data = Ext.decode(response.responseText);
 
                    if (data != null && typeof(data) != "undefined") {                                
                        var columnCount = 11; //多少列
                        var maxColumn = [];
 
                        for(var i=0;i<data.length;i++){
                            var value = data[i].ITEM_VALUE;
                            var displayName = data[i].ITEM_NAME;
 
                            var chkbox = $("<label class='checkbox-inline'><input type='checkbox'  class='temp' value="
                                    +value+"><span>"+displayName+"</span></label>");
                            $("#guiderTypeList").append(chkbox);
 
                            if ((i+1)%columnCount==0) { // 最后一列换行
                                $("#guiderTypeList").append($("<br/>"));
                            }
 
                            var mod=(i+1)%columnCount;
                            if (typeof(maxColumn[mod])=="undefined") {
                                maxColumn[mod]=0;
                            }
 
                            if(maxColumn[mod] < displayName.length){
                                maxColumn[mod] = displayName.length; //记住每列最长的中文字个数
                            }                                    
                        }
 
                        // 设置每列对其的宽度,一个文字占13px
                        $("#guiderTypeList").children("label").each(function(i, item){
                            var mod=(i+1)%columnCount;
                            $(item).css("width", maxColumn[mod]*13 + 20); //以最长中文字数为改列的宽度
                        });                            
                    }else {
                        Ext.MessageBox.alert('加载导购类型失败', '后台返回数据为空, 无法初始导购类型');
                    }
                },
                failure : function(response, options) {
                    Ext.MessageBox.alert('加载导购类型失败', '请求超时或网络故障, 错误编号:' + response.status);
                }
            });
        }
上一篇:duilib 实现 XML重用(item完全重合的CList)


下一篇:MT【327】两道不等式题