ComponentArt控制項分析之ComboBox(2)

來源:互聯網
上載者:User

一.來看下資料資料解析

首先後台先產生一種資料格式,這種格式跟JSON差不多(不知道為什麼不用JSON),查看HTML原始碼

ComboBox2.Data = [[['Text','a'],['Value','b']],[['Text','b'],['Value','c']],[['Text','c'],['Enabled',0],['Value','b']],[['CssClass','comboItemHover'],['Text','d'],['Value','c'],['Id','ComboBoxItem1']],[['Text','a'],['Value','b']],[['Text','b'],['Value','c']],[['Text','c'],['Enabled',0],['Value','b']],[['CssClass','comboItemHover'],['Text','d'],['Value','c'],['Id','ComboBoxItem2']],[['Text','a'],['Value','b']],[['Text','b'],['Value','c']],[['Text','c'],['Enabled',0],['Value','b']],[['CssClass','comboItemHover'],['Text','d'],['Value','c'],['Id','ComboBoxItem3']],[['Text','a'],['Value','b']],[['Text','b'],['Value','c']],[['Text','c'],['Enabled',0],['Value','b']],[['CssClass','comboItemHover'],['Text','d'],['Value','c'],['Id','hello']]];

2.需要定義一個ComboBoxItem對象(自然要定義資料集合類型了),其中js也要定義,資料結構採用HashTable,尋找速度快.其中定義了一個JavaScriptArray用來轉換資料

  private string BuildStorage()  {   JavaScriptArray arNodeList = new JavaScriptArray();     foreach (ComboBoxItem oItem in this.Items)   {    ProcessItem(oItem, arNodeList);   }    string strList=arNodeList.ToString();    return strList;  }  private void ProcessItem(ComboBoxItem oItem, ArrayList arNodeList)  {     ArrayList itemProperties = new ArrayList();   foreach (string propertyName in oItem.Properties.Keys)   {    switch (propertyName.ToLower())    {     // bools     case "enabled": itemProperties.Add(new object[] { "Enabled", oItem.Enabled }); break;       // normal string handling     default:      itemProperties.Add(new object[] { propertyName, oItem.Properties[propertyName] });      break;    }   }   arNodeList.Add(itemProperties);  }

3.前台處理資料

資料得到以後就要處理

前段的ComboBox(Initialize)初始化時會調用Render方法,Render方法會調用RenderDropDown方法,RenderDropDown方法調用RenderItem方法,把每項都呈現出來

聯繫我們

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