jquery+ligerform三級聯動下拉框

來源:互聯網
上載者:User

標籤:style   blog   http   io   ar   color   sp   for   on   

如下為ligerform裡的三級聯動下拉框:

 var formData=[         {display:"縣區",name:"QY",newline:true,labelWidth:100,width:220,space:50,type:"select",group:"地區資訊",groupicon:"@Url.Content("~/Content/icons/32X32/communication.gif")",comboboxName:"QYName",options:{valueFieldID:"QY" }},          {display:"鎮/街道",name:"ZHEN",newline:false,labelWidth:100,width:220,space:50,type:"select",comboboxName:"ZHENName",options:{valueFieldID:"ZHEN"}},         {display:"村/道路",name:"CUN",newline:true,labelWidth:100,width:220,space:50,type:"select",comboboxName:"CUNName",options:{valueFieldID:"CUN"}}]                            //建立表單結構         var mainform = $("#mainform");           mainform.ligerForm({              inputWidth: 280,             fields: formData,             toJSON:JSON2.stringify         })

需求:載入頁面時,載入“縣區”下拉框;選擇縣區後,載入“鎮/街道”下拉框;選擇鎮/街道後,載入“村/道路”下拉框。

代碼如下:

        //載入地區下拉框        $.getJSON(rootPath1+ ‘CaseInfoFC/GetAreasForSelect?idfield=id&textfield=text&where=‘+ JSON2.stringify({            op: ‘and‘,            rules: [{ field: ‘ParentCode‘, value: ‘4413‘, op: ‘equal‘ }]  //4413-一級地區的parentcode        }) ,             function(json){                 var newData = new Array();                for (i = 0; i < json.length; i++)                {                    newData.push(json[i]);                }                liger.get("QYName").setData(newData);             });         //選擇地區後,載入鎮/小區下拉框         $("#QYName").ligerComboBox({ onSelected: function (newvalue)         {             if(newvalue==null) return;              var newData = new Array();             $.getJSON(rootPath1+ ‘CaseInfoFC/GetAreasForSelect?idfield=id&textfield=text&where=‘+ JSON2.stringify({                 op: ‘and‘,                 rules: [{ field: ‘ParentCode‘, value: newvalue, op: ‘equal‘ }]              }) ,             function(json){                              for (i = 0; i < json.length; i++)                {                    newData.push(json[i]);                }                liger.get("ZHENName").setData("");                //liger.get("ZHENName").selectValue(null);//注釋掉,否則載入不到後台傳過來的值                liger.get("ZHENName").setData(newData);            })         }});        //選擇鎮/街道後,載入村/小區/道路下拉框         $("#ZHENName").ligerComboBox({ onSelected: function (newvalue)         {             if(newvalue==null) return;              var newData = new Array();                 $.getJSON(rootPath1+ ‘CaseInfoFC/GetAreasForSelect?idfield=id&textfield=text&where=‘+ JSON2.stringify({                     op: ‘and‘,                     rules: [{ field: ‘ParentCode‘, value: newvalue, op: ‘equal‘ }]                  }) ,            function(json){                             for (i = 0; i < json.length; i++)               {                   newData.push(json[i]);               }               liger.get("CUNName").setData("");               // liger.get("CUNName").selectValue(null);               liger.get("CUNName").setData(newData);           })         }});


需求2:把三級下拉框選中值儲存到某一個表,以後開啟詳情頁時,讀取這個表中儲存的下拉框選中的值,初始化下拉框。

該需求也是涉及到select初始化問題,與上一篇的要求2 http://www.cnblogs.com/goodgirlmia/p/4165216.html 同理可得,這裡就再重複了。

 

關於ligerform的select的取值與賦值,見之前發的文章:http://www.cnblogs.com/goodgirlmia/p/4164878.html

jquery+ligerform三級聯動下拉框

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.