Ext.Net中动态创建Combox及动态添加其Items【总结】

                Ext.Net.ComboBox combox = new Ext.Net.ComboBox();
                combox.ID = TCMUtility.GuidToControlID(formField.SYSID, "field");
                combox.Height = Unit.Parse("25px");
                combox.Width = Unit.Parse("280px");
                combox.LabelAlign = LabelAlign.Right;
                combox.FieldLabel = formField.FIELDNAME;
                combox.X = 0;
                combox.Y = numY;
                combox.Editable = false;
                combox.Resizable = true;
                combox.AllowBlank = formField.ALLOWNULL;

                JsonReader ar = new JsonReader();
                RecordField rf = new RecordField("DATA", RecordFieldType.String);
                RecordField rf2 = new RecordField("VALUE", RecordFieldType.String);
                ar.Fields.Add(rf);
                ar.Fields.Add(rf2);
                Store myStore = new Store();
                myStore.Reader.Add(ar);
               

                //如果是下拉框,需要把所有下拉值填充进去,以便用户选择
                List<StringEntity> list = new List<StringEntity>();
                string valueList = formField.VALUELIST ?? "";
                if (valueList.Length != 0)
                {
                    string[] numValue = valueList.Split(';');
                    for (int j = 0; j < numValue.Count(); j++)
                    {
                        StringEntity value = new StringEntity();
                        value.DATA = numValue[j].ToString();
                        value.VALUE = numValue[j].ToString();
                        list.Add(value);
                    }

                    myStore.DataSource = list;
                    myStore.DataBind();                                
                }
                combox.Store.Add(myStore);
                combox.DisplayField = "DATA";
                combox.ValueField = "VALUE";

posted @ 2012-02-17 14:48  zp_Alex  阅读(2373)  评论(0编辑  收藏  举报