Ext js中CheckBoxGroup的動態綁定

來源:互聯網
上載者:User

標籤:

    <script  type="text/jscript">     var WinXianCode;    function SearchGetXianLuF(Type)    {        if(!WinXianCode)        {            //建立表單框             WinXianCode=new Ext.Window({           id:‘WinXianCode‘,           width:700,           height:600,           closeAction:‘hide‘,           autoScroll:true,           model:true,           items : [                    new Ext.form.FormPanel({                        frame:true,                        defaultType:‘textfield‘,                        id:‘c-form‘,                        labelWidth :40,                        defaults:{width: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(‘\n‘));                                                                                }                                        if(Type==2)                                        {                                          //費用不包含                                         Ext.getCmp("ratedetailno").setValue(xq.join(‘\n‘));                                        }                                    }                              }                            }                      });                    }                    //擷取報價:結束                                       //定義多選的報價數組:開始                   var checkGroup = new Ext.form.CheckboxGroup({                        id:‘QuotedPriceS‘,                        xtype:‘checkboxgroup‘,                        fieldLabel:‘報價‘,                        width: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)));

 

Ext js中CheckBoxGroup的動態綁定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.