• Ext js中CheckBoxGroup的动态绑定


        <script  type="text/jscript">
         var WinXianCode;
        function SearchGetXianLuF(Type)
        {
            if(!WinXianCode)
            {
                //创建窗体框
                 WinXianCode=new Ext.Window({
               id:'WinXianCode',
               700,
               height:600,
               closeAction:'hide',
               autoScroll:true,
               model:true,
               items : [
                        new Ext.form.FormPanel({
                            frame:true,
                            defaultType:'textfield',
                            id:'c-form',
                            labelWidth :40,
                            defaults:{700},
                            })
                       ],
               title:'报价项目包含不包含项'
              });
            }
            QuotedPriceView(Type);
            //弹出窗体
            WinXianCode.show('XianLuCode');
        }
        </script>
        
        
        <script type="text/javascript">
    
        //报价数据加载
        function QuotedPriceView(Type)
        {
            var QuotedPriceCheckboxItems = [];
            Ext.MessageBox.wait('报价数据正在加载','请稍等...');
            Ext.Ajax.request({  
                url:'QuotedPrice.aspx',
                method : 'post',
                success: function (r) {  
                    Ext.MessageBox.hide();
                    var data = Ext.decode(r.responseText).QuotedPricelist; 
                    if(data.length>0)
                    {
                        //获取报价:开始
                        for(var i=0;i<data.length;i++)
                        {
                          QuotedPriceCheckboxItems.push
                          ({
                               id:'CheckBox'+data[i].name, 
                               name:data[i].name, 
                               boxLabel: data[i].boxLabel,
                               inputValue:data[i].inputValue,
                               listeners:{
                                  check:function(el,checked){
                                        var coninter=Ext.getCmp("QuotedPriceS");
                                        if(coninter!=undefined)
                                        {
                                            var inter=coninter.items;
                                            var xq=[];  
                                            for (var i = 0; i < inter.length; i++)  
                                            {  
                                                if (inter!=null && inter.get(i).checked)  
                                                {  
                                                    xq.push(inter.get(i).inputValue); 
                                                }  
                                            }  
                                            if(Type==1)
                                            {
                                             //费用包含
                                             Ext.getCmp("ratedetail").setValue(xq.join('
    '));
                                            
                                            }
                                            if(Type==2)
                                            {
                                              //费用不包含
                                             Ext.getCmp("ratedetailno").setValue(xq.join('
    '));
                                            }
                                        }
                                  }
                                }
                          });
                        }
                        //获取报价:结束
                        
                       //定义多选的报价数组:开始
                       var checkGroup = new Ext.form.CheckboxGroup({
                            id:'QuotedPriceS',
                            xtype:'checkboxgroup',
                            fieldLabel:'报价',
                            1200,
                            columns:1,
                            items:QuotedPriceCheckboxItems
                            });
                      //定义多选的报价数组:结束
                      
                      //多选的容器:开始
                      var cbp = Ext.getCmp("c-form");
                      cbp.items.add(checkGroup);
                      cbp.show();
                      cbp.doLayout();  
                      //多选的容器:结束
                    }
                }  
            });  
        }    
        </script>
    View Code

    后台返回的json数据:

    JArray jar = new JArray();
            DataSet db_QuotedPrice = SPBll.Packages.getQuotedPrice();
            foreach (DataRow row in db_QuotedPrice.Tables[0].Rows)
            {
                jar.Add(new JObject(
                    new JProperty("name", row["id"].ToString()),
                    new JProperty("inputValue", row["cname"].ToString()),
                    new JProperty("boxLabel", row["cname"].ToString())
                    ));
            }
            Response.Write(new JObject(new JProperty("QuotedPricelist", jar)));
  • 相关阅读:
    X 如何在mysql客户端即mysql提示符下执行操作系统命令
    X MySQL UNDO表空间独立和截断 ,mysql undo 的历史
    X Mysql5.7忘记root密码及mysql5.7修改root密码的方法
    X mysql密码的安全策略ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    二分法查找
    elasticsearch API
    logstash的基础
    elasticsearch的基础
    Linux的进程管理
    Linux的网卡配置
  • 原文地址:https://www.cnblogs.com/ly77461/p/5900197.html
Copyright © 2020-2023  润新知