Exemple #1
0
        //private void AfterDataBind()
        //{
        //    //// 必须重新计算模拟数的数据
        //    //mustReCalculateSimulateTreeData = true;
        //}

        #endregion

        #region IPostBackDataHandler Members

        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            string postText  = postCollection[postDataKey];
            string postValue = postCollection[SelectedValueHiddenFieldID];

            ListItem item = Items.FindByValue(postValue);

            if (item != null && item.Text == postText)
            {
                // 本次选中的是下拉项
                if (SelectedValue != postValue)
                {
                    SelectedValue = postValue;
                    FState.BackupPostDataProperty("SelectedValue");
                    return(true);
                }
            }
            else
            {
                // 本次是用户输入的值
                if (Text != postText)
                {
                    SelectedValue = null;
                    FState.BackupPostDataProperty("SelectedValue");

                    Text = postText;
                    FState.BackupPostDataProperty("Text");
                    return(true);
                }
            }


            return(false);
        }
Exemple #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public ControlBase()
        {

            _state = new FState(this);

            AddServerAjaxProperties("Hidden", "Enabled");
            AddClientAjaxProperties();

        }
Exemple #3
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public virtual bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            bool postCollapsed = Convert.ToBoolean(postCollection[CollapsedHiddenFieldID]);

            if (Collapsed != postCollapsed)
            {
                Collapsed = postCollapsed;
                FState.BackupPostDataProperty("Collapsed");
            }

            return(false);
        }
Exemple #4
0
        //private JArray GetItemsJArray()
        //{
        //    JArray ja = new JArray();
        //    int itemIndex = 0;
        //    foreach (CheckItem item in Items)
        //    {
        //        JObject jo = new JObject();
        //        jo.Add("inputValue", item.Value);
        //        jo.Add("boxLabel", item.Text);
        //        jo.Add("name", UniqueID + "_" + itemIndex.ToString());
        //        if (item.Selected)
        //        {
        //            jo.Add("checked", true);
        //        }

        //        ja.Add(jo);

        //        itemIndex++;
        //    }

        //    return ja;
        //}

        #endregion

        #endregion

        #region DataBind

        /// <summary>
        /// 绑定到数据源
        /// </summary>
        public override void DataBind()
        {
            base.DataBind();

            if (_dataSource != null)
            {
                // 1. 首先清空 Items 属性
                Items.Clear();

                // 2. 绑定到数据源
                if (_dataSource is IDataReader)
                {
                    DataTable dataTable = new DataTable();
                    dataTable.Load(_dataSource as IDataReader);

                    DataBindToDataTable(dataTable);
                }
                else if (_dataSource is DataView || _dataSource is DataSet || _dataSource is DataTable)
                {
                    DataTable dataTable = null;
                    if (_dataSource is DataView)
                    {
                        dataTable = ((DataView)_dataSource).ToTable();
                    }
                    else if (_dataSource is DataSet)
                    {
                        dataTable = ((DataSet)_dataSource).Tables[0];
                    }
                    else
                    {
                        dataTable = ((DataTable)_dataSource);
                    }

                    DataBindToDataTable(dataTable);
                }
                else if (_dataSource is IEnumerable)
                {
                    DataBindToEnumerable((IEnumerable)_dataSource);
                }
                else
                {
                    throw new Exception("DataSource doesn't support data type: " + _dataSource.GetType().ToString());
                }

                // F_Items属性不是ServerAjaxProperty,所以只在页面第一次加载时判断是否改变
                if (!Page.IsPostBack)
                {
                    FState.AddModifiedProperty("F_Items");
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public virtual bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            string postValue = postCollection[ActiveTabIndexHiddenFieldID];

            int postActiveTabIndex = Convert.ToInt32(postValue);

            if (ActiveTabIndex != postActiveTabIndex)
            {
                ActiveTabIndex = postActiveTabIndex;
                FState.BackupPostDataProperty("ActiveTabIndex");
            }

            return(false);
        }
Exemple #6
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            if (EnablePress)
            {
                bool pressed = Convert.ToBoolean(postCollection[PressedHiddenFieldID]);
                if (pressed != Pressed)
                {
                    Pressed = pressed;
                    FState.BackupPostDataProperty("Pressed");
                }
            }

            return(false);
        }
Exemple #7
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public virtual bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            //string postValue = postCollection[postDataKey];
            string[] selectedValueArray = StringUtil.GetStringListFromString(postCollection[SelectedValueArrayHiddenFieldID]).ToArray();
            string   postValue          = selectedValueArray.Length > 0 ? selectedValueArray[0] : String.Empty;

            if (SelectedValue != postValue)
            {
                SelectedValue = postValue;
                FState.BackupPostDataProperty("SelectedValue");
                return(true);
            }
            return(false);
        }
Exemple #8
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public override bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            base.LoadPostData(postDataKey, postCollection);

            bool postHidden = Convert.ToBoolean(postCollection[HiddenHiddenFieldID]);

            if (Hidden != postHidden)
            {
                Hidden = postHidden;
                FState.BackupPostDataProperty("Hidden");
            }

            return(false);
        }
Exemple #9
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            //string postValue = postCollection[postDataKey];
            //bool postChecked = !String.IsNullOrEmpty(postValue);
            bool postChecked = Convert.ToBoolean(postCollection[CheckedHiddenFieldID]);

            if (Checked != postChecked)
            {
                Checked = postChecked;
                FState.BackupPostDataProperty("Checked");
                return(true);
            }

            return(false);
        }
Exemple #10
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public virtual bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            string postSelectedDateStr = postCollection[SelectedDateHiddenFieldID];

            if (!String.IsNullOrEmpty(postSelectedDateStr))
            {
                DateTime currentSelectedDate = DateTime.ParseExact(postSelectedDateStr, DateFormatString, CultureInfo.InvariantCulture);
                if (currentSelectedDate != SelectedDate)
                {
                    SelectedDate = currentSelectedDate;
                    FState.BackupPostDataProperty("SelectedDate");
                }
            }

            return(false);
        }
Exemple #11
0
        /// <summary>
        /// 处理回发数据
        /// 回发到服务器,判断控件的属性是否变化,
        /// 如果变化返回true,则RaisePostDataChangedEvent
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            string postValue = postCollection[UniqueID];

            //// Extjs4.0.1 没能正确的设置 htmleditor 的提交隐藏字段,这个在更高版本中可能要删除
            //string postValue = postCollection[ClientID + "_Text"];

            if (postValue != null && Text != postValue)
            {
                Text = postValue;
                FState.BackupPostDataProperty("Text");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #12
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            // 不管单选框是否在分组中,每个单选框的Checked都在POST参数中
            bool postChecked = Convert.ToBoolean(postCollection[CheckedHiddenFieldID]);

            if (Checked != postChecked)
            {
                Checked = postChecked;
                FState.BackupPostDataProperty("Checked");
                return(true);
            }

            //if (String.IsNullOrEmpty(GroupName))
            //{
            //    // This radio button is not in a group
            //    string postValue = postCollection[postDataKey];
            //    bool postChecked = !String.IsNullOrEmpty(postValue);
            //    if (Checked != postChecked)
            //    {
            //        Checked = postChecked;
            //        FState.BackupPostDataProperty("Checked");
            //        return true;
            //    }
            //}
            //else
            //{
            //    // This radio is in a group
            //    string postValue = postCollection[GroupName];
            //    if (!String.IsNullOrEmpty(postValue))
            //    {
            //        bool postChecked = (ClientID == postValue) ? true : false;
            //        if (Checked != postChecked)
            //        {
            //            Checked = postChecked;
            //            FState.BackupPostDataProperty("Checked");
            //            return true;
            //        }
            //    }
            //}

            return(false);
        }
Exemple #13
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public virtual bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            //List<string> selectedValues = new List<string>();
            //for (int i = 0, count = Items.Count; i < count; i++)
            //{
            //    if (!String.IsNullOrEmpty(postCollection[postDataKey + "_" + i.ToString()]))
            //    {
            //        CheckItem item = Items[i];
            //        selectedValues.Add(item.Value);
            //    }
            //}
            //string[] selectedValueArray = selectedValues.ToArray();

            string[] selectedValueArray = StringUtil.GetStringListFromString(postCollection[SelectedValueArrayHiddenFieldID]).ToArray();
            if (!StringUtil.CompareStringArray(selectedValueArray, SelectedValueArray))
            {
                SelectedValueArray = selectedValueArray;
                FState.BackupPostDataProperty("SelectedValueArray");
                return(true);
            }

            return(false);
        }
Exemple #14
0
        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public virtual bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            string postValue = postCollection[UniqueID];

            // 只有启用表单控件时,才判断Text是否改变
            // 对于TextBox,如果禁用了(disabled="disabled")则postValue == null,也就是说此表单字段不会提交到服务器(这是浏览器行为)。
            if (Enabled)
            {
                // If post value is empty, null or equals to the EmptyText property, we can consider it to be String.Empty.
                if (String.IsNullOrEmpty(postValue) || postValue == EmptyText)
                {
                    postValue = String.Empty;
                }

                if (Text != postValue)
                {
                    Text = postValue;
                    FState.BackupPostDataProperty("Text");
                    return(true);
                }
            }
            return(false);
        }
Exemple #15
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            // 确保 F_Items 和 SelectedValue 在页面第一次加载时都存在于f_state中
            FState.AddModifiedProperty("F_Items");
            FState.AddModifiedProperty("SelectedValueArray");

            base.OnFirstPreRender();

            #region options

            if (Required)
            {
                OB.AddProperty("allowBlank", false);
                if (!String.IsNullOrEmpty(RequiredMessage))
                {
                    OB.AddProperty("blankText", RequiredMessage);
                }
            }


            OB.RemoveProperty("name");

            if (ColumnNumber <= 0)
            {
                OB.AddProperty("columns", "auto");
            }
            else
            {
                OB.AddProperty("columns", ColumnNumber);
            }

            if (ColumnVertical)
            {
                OB.AddProperty("vertical", true);
            }

            //OB.AddProperty("name", UniqueID);

            #endregion

            #region Items

            /*
             * string xstateName = String.Format("{0}_xstate", XID);
             * string xitemsName = String.Format("{0}_xitems", XID);
             * string hasDataName = xstateName;
             *
             * string xstate = OB.GetProperty("f_state");
             * OB.AddProperty("f_state", xstateName, true);
             *
             * string jsState = String.Format("var {0}={1};", xstateName, xstate);
             *
             * if (!FState.ModifiedProperties.Contains("F_Items"))
             * {
             *  xstate = ConvertPropertiesToJObject(new List<string> { "F_Items", "SelectedValueArray" }).ToString(Formatting.None);
             *  jsState += String.Format("var {0}={1};", xitemsName, xstate);
             *  hasDataName = xitemsName;
             * }
             *
             * OB.AddProperty("name", UniqueID);
             * OB.AddProperty("items", String.Format("F.util.resolveCheckBoxGroup('{0}',{1},false)", UniqueID, hasDataName), true);
             */

            OB.AddProperty("name", UniqueID);
            OB.AddProperty("items", String.Format("F.util.resolveCheckBoxGroup('{0}',{1},false)", UniqueID, GetFStateScriptID()), true);


            #endregion

            #region AutoPostBack

            if (AutoPostBack)
            {
                // 道理和RadioButtonList类似。
                //OB.Listeners.AddProperty("change", String.Format("function(group,checkedArray){{if(typeof(checkedArray)!=='boolean'){{{0}}}}}", GetPostBackEventReference()), true);
                AddListener("change", String.Format("if(typeof(checkedArray)!=='boolean'){{{0}}}", GetPostBackEventReference()), "group", "checkedArray");
            }

            /*
             * if (!String.IsNullOrEmpty(SelectedValue))
             * {
             *  OB.AddProperty("value", SelectedValue);
             * }
             */

            #region old code
            //string autoPostBackScript = String.Empty;
            //if (AutoPostBack)
            //{
            //    //// change 事件只有在失去焦点时才触发,是不及时的
            //    //OB.Listeners.RemoveProperty(OptionName.Change);
            //    //OB.Listeners.AddProperty(OptionName.Check, String.Format("function(newValue,oldValue){{\r\nbox_pageStateChange();alert(newValue+':'+oldValue);\r\n}}"), true);

            //    string selectScript = String.Format("function(newValue,oldValue){{\r\nalert(newValue+':'+oldValue);\r\n}}");
            //    selectScript = String.Format("{0}.on('{1}',{2},box,{{delay:0}});", ClientID, OptionName.Check, selectScript);

            //    autoPostBackScript += selectScript;
            //}

            //string backgroundColorStyle = String.Empty;
            //if (EnableBackgroundColor)
            //{
            //    backgroundColorStyle = AboutConfig.GetDefaultBackgroundColor(PageManagerInstance.Theme.ToString());
            //}
            //else if (EnableLightBackgroundColor)
            //{
            //    backgroundColorStyle = AboutConfig.GetLightBackgroundColor(PageManagerInstance.Theme.ToString());
            //}

            //if (!String.IsNullOrEmpty(backgroundColorStyle))
            //{
            //    string backgroundColorScript = String.Format("Ext.each(X.{0}.el.query('.x-panel-body'),function(item,index){{Ext.get(item).setStyle('background-color','{1}');}});", ClientJavascriptID, backgroundColorStyle);

            //    string renderScript = "(function(){" + backgroundColorScript + "}).defer(20);";
            //    OB.Listeners.AddProperty("render", "function(component){" + renderScript + "}", true);
            //}

            #endregion

            #endregion


            // EXTJS的BUG,不支持默认Readonly=true的情况,需要自己修正
            if (Readonly)
            {
                //OB.Listeners.AddProperty("render", JsHelper.GetFunction("cmp.setReadOnly(true);", "cmp"), true);
                AddListener("render", "cmp.setReadOnly(true);", "cmp");
            }


            string jsContent = String.Format("var {0}=Ext.create('Ext.form.CheckboxGroup',{1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
Exemple #16
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            // 确保 F_Items 和 SelectedValue 在页面第一次加载时都存在于f_state中
            FState.AddModifiedProperty("F_Items");
            FState.AddModifiedProperty("SelectedValue");

            base.OnFirstPreRender();

            #region examples

            //var nextStepList = [
            //    ['审核', '1'],
            //    ['不审核', '2']
            //];
            //var nextStepStore = new Ext.data.SimpleStore({
            //    fields: ['text', 'value'],
            //    data: nextStepList
            //});
            //{
            //    xtype:'combo',
            //    store: nextStepStore,
            //    displayField:'text',
            //    valueField:'value',
            //    typeAhead: true,
            //    mode: 'local',
            //    triggerAction: 'all',
            //    value:'1',
            //    emptyText:'请选择下一步',
            //    selectOnFocus:true,
            //    allowBlank:false,
            //    fieldLabel: '下一步',
            //    labelSeparator:'&nbsp;<span style="color:red;vertical-align:text-bottom;">*</span>',
            //    name: 'nextStep',
            //    anchor:'95%'
            //}

            #endregion

            #region Properties

            if (EnableEdit)
            {
                OB.AddProperty("editable", true);
            }
            else
            {
                OB.AddProperty("editable", false);
            }


            if (ForceSelection)
            {
                OB.AddProperty("forceSelection", true);
            }
            else
            {
                OB.AddProperty("forceSelection", false);
            }

            //if (Resizable)
            //{
            //    OB.AddProperty("resizable", true);
            //}

            OB.AddProperty("hiddenName", SelectedValueHiddenFieldID);


            JsObjectBuilder storeBuilder = new JsObjectBuilder();
            storeBuilder.AddProperty("fields", "['value','text','enabled','prefix']", true);
            storeBuilder.AddProperty("data", String.Format("F.simulateTree.transform({0}.F_Items)", GetFStateScriptID()), true);
            OB.AddProperty("store", String.Format("Ext.create('Ext.data.ArrayStore',{0})", storeBuilder), true);

            OB.AddProperty("value", String.Format("{0}.SelectedValue", GetFStateScriptID()), true);

            OB.AddProperty("tpl", "F.util.ddlTPL", true);

            OB.AddProperty("queryMode", "local");
            OB.AddProperty("triggerAction", "all");

            #region old code
            //OB.AddProperty("mode", "local");
            //// 点击下拉按钮时显示全部内容
            //OB.AddProperty("triggerAction", "all");
            //// 必须选中一个值,不能自己输入内容
            //OB.AddProperty("forceSelection", true);
            //// 此下拉列表控件不可以编辑
            //OB.AddProperty("editable", false);

            //OB.AddProperty(OptionName.Title, "Title");
            //if (TypeAhead) OB.AddProperty(OptionName.TypeAhead, true);
            //OB.AddProperty(OptionName.SelectOnFocus, true);

            //// SelectedValue可以为空
            //if (!String.IsNullOrEmpty(SelectedValue))
            //{
            //    OB.AddProperty("value", SelectedValue);
            //}
            #endregion

            #endregion

            #region old code

            //string hiddenFieldsScript = String.Empty;
            //if (AutoPostBack)
            //{
            //    hiddenFieldsScript += GetSetHiddenFieldValueScript(LastSelectedValueHiddenID, SelectedValue);
            //}

            //string disableSelectRowIndexsString = GetDisableSelectRowIndexsString();
            //string disableSelectRowIndexsScript = GetSetHiddenFieldValueScript(DisableRowIndexsHiddenID, disableSelectRowIndexsString);

            //// TODO:
            //// 这个要放在加载数据的前面,因为加载数据时需要渲染UI,渲染UI时需要用到这个隐藏字段的值
            //if (AjaxPropertyChanged("DisableSelectRowIndexsString", disableSelectRowIndexsString))
            //{
            //    AddAjaxPropertyChangedScript(disableSelectRowIndexsScript);
            //}


            // 不管是不是disableSelectFields.Count > 0,都要执行下面的语句,因为可能页面加载时为0,在Ajax后不为零
            //if (disableSelectFields.Count > 0)
            //OB.AddProperty(OptionName.Tpl, String.Format("'<tpl for=\".\"><div class=\"x-combo-list-item {{[F.util.isHiddenFieldContains(\"{0}\",xindex-1) ? \"f-combo-list-item-disable-select\" : \"\"]}}\">{{text}}</div></tpl>'", DisableSelectRowIndexsHiddenID), true);
            //var tplStr = "'<tpl for=\".\"><div class=\"x-combo-list-item\">{text}</div></tpl>'";
            //var tplStr = "new Ext.XTemplate('<tpl for=\".\"><div class=\"x-combo-list-item\">{text}</div></tpl>')";

            //var tplStr = "<tpl for=\".\"><div class=\"x-combo-list-item <tpl if=\"!enabled\">x-combo-list-item-disable</tpl>\">{prefix}{text}</div></tpl>";
            //OB.AddProperty("tpl", tplStr);
            //OB.AddProperty("tpl", tplStr.Replace("#DisableRowIndexsHiddenID#", DisableRowIndexsHiddenID), true);


            //string setSimulateTreeTextFunctionScript = String.Empty;
            //string setSimulateTreeTextScript = String.Empty;
            //if (EnableSimulateTree)
            //{
            //    string setSimulateTextScript = String.Format("var text=Ext.get('{0}').dom.value;if(text.lastIndexOf('<img')>=0){{Ext.get('{0}').dom.value=F.util.stripHtmlTags(text);}}", ClientID);
            //    setSimulateTreeTextFunctionScript = String.Format("{0}_setSimulateText=function(){{{1}}};", ClientJavascriptID, setSimulateTextScript);

            //    // 加载完毕后,显示选中的值
            //    //AddAbsoluteStartupScript(String.Format("{0}_setSimulateText();", ClientJavascriptID));
            //    // 下拉列表加载完毕后,立即去掉前面图片的HTML标签
            //    string renderScript = JsHelper.GetDeferScript(String.Format("{0}_setSimulateText();", ClientJavascriptID), 20); // "(function(){" + String.Format("{0}_setSimulateText();", ClientJavascriptID) + "}).defer(20);";
            //    OB.Listeners.AddProperty(OptionName.EVENT_RENDER, "function(component){" + renderScript + "}", true);
            //}


            //string simulateTreeAllScript = String.Empty;
            //if (EnableSimulateTree)
            //{
            //    // 在选中一项后,立即去掉前面图片的HTML标签
            //    simulateTreeAllScript += "\r\n";
            //    //string simulateTreeScript = String.Format("function(ddl,record,index){{var text=record.data.text;var startDivIndex=text.lastIndexOf('</div>');text=text.substr(startDivIndex+6);Ext.get('{0}').dom.value=text;}}", ClientID);
            //    string simulateTreeScript = String.Format("function(ddl,record,index){{X.{0}_setSimulateText();}}", ClientJavascriptID);
            //    simulateTreeScript = String.Format("{0}.on('{1}',{2},box,{{delay:0}});", ClientJavascriptID, OptionName.Select, simulateTreeScript);
            //    //AddAbsoluteStartupScript( simulateTreeScript);
            //    simulateTreeAllScript += simulateTreeScript;

            //    simulateTreeAllScript += "\r\n";
            //    string simulateTreeBlurScript = String.Format("function(ddl){{X.{0}_setSimulateText();}}", ClientJavascriptID);
            //    simulateTreeBlurScript = String.Format("{0}.on('{1}',{2},box,{{delay:10}});", ClientJavascriptID, OptionName.Blur, simulateTreeBlurScript);
            //    //AddAbsoluteStartupScript( simulateTreeBlurScript);
            //    simulateTreeAllScript += simulateTreeBlurScript;
            //}



            // These are default values, which are assignment in extender.js.
            //OB.AddProperty("displayField", "text");
            //OB.AddProperty("valueField", "value");
            //OB.AddProperty("store", "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})", true);

            //string dataScript = String.Empty;
            //string fields = "['value','text','enabled','prefix']";
            //string storeScript = "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})";//", fields, GetDataArrayString()); // GetDataArrayString()

            //OB.AddProperty(OptionName.Store, String.Format("new Ext.data.ArrayStore({{fields:['value','text'],data:{0}}})", dataArrayString), true);
            //OB.AddProperty("store", String.Format("{0}_data", XID), true);
            //string dataScript = String.Format("{0}_data=new Ext.data.ArrayStore({{fields:['value','text'],data:{1}}});", ClientJavascriptID, dataArrayString);
            //sb.AppendFormat("this.{0}_store=new Ext.data.SimpleStore({{fields:['text', 'value'],data:this.{0}_data}});", ClientJavascriptID);
            #endregion

            #region AutoPostBack

            StringBuilder beforeselectSB = new StringBuilder();
            // 是否能选中一项(如果此项不能选中,则点击没用)
            //beforeselectSB.AppendFormat("if(F.util.isHiddenFieldContains('{0}',index)){{return false;}}", DisableRowIndexsHiddenID);
            beforeselectSB.Append("if(!record.data.enabled){return false;}");

            if (AutoPostBack)
            {
                beforeselectSB.Append("cmp.f_tmp_lastvalue=cmp.getValue();");

                string selectScript = "if(cmp.f_tmp_lastvalue!==cmp.getValue()){" + GetPostBackEventReference() + "}";
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(selectScript, "cmp"), true);
            }

            OB.Listeners.AddProperty("beforeselect", JsHelper.GetFunction(beforeselectSB.ToString(), "cmp", "record", "index"), true);

            #region old code
            //if (AutoPostBack)
            //{
            //    // Note: we can't use change event, because it get triggered when the combox lost focus, which is not in time.
            //    // Beforeselect - If current select item is not changed, don't PostBack.
            //    string beforeselectScript = String.Format("function(ddl,record,index){{Ext.get('{0}').dom.value=Ext.get('{1}').dom.value;}}", LastSelectedValueHiddenID, SelectedValueHiddenID);
            //    beforeselectScript = String.Format("{0}.on('{1}',{2},X,{{delay:0}});", XID, "beforeselect", beforeselectScript);
            //    //AddAbsoluteStartupScript( beforeselectScript);
            //    autoPostBackScript += beforeselectScript;

            //    // Select
            //    string selectScript = String.Format("function(ddl,record,index){{if(record.data.value!=Ext.get('{0}').dom.value){{{1}}}}}", LastSelectedValueHiddenID, GetPostBackEventReference());
            //    selectScript = String.Format("{0}.on('{1}',{2},X,{{delay:0}});", XID, "select", selectScript);
            //    //AddAbsoluteStartupScript( selectScript);
            //    autoPostBackScript += selectScript;


            //    //OB.Listeners.RemoveProperty(OptionName.Change);
            //    //OB.Listeners.AddProperty(OptionName.Change, String.Format("function(ddl,newValue,oldValue){{box_pageStateChange();alert(newValue+':'+oldValue);}}"), true);
            //}
            #endregion

            #endregion

            #region Listeners - render

            //string renderScript = "cmp.f_loadData();cmp.f_setValue();";

            //OB.Listeners.AddProperty("render", JsHelper.GetFunction(renderScript, "cmp"), true);

            #endregion

            #region AddStartupScript

            string contentScript = String.Format("var {0}=Ext.create('Ext.form.field.ComboBox',{1});", XID, OB.ToString());

            AddStartupScript(contentScript);

            #region old code
            //List<string> totalModifiedProperties = FState.GetTotalModifiedProperties();
            //StringBuilder loadDataSB = new StringBuilder();
            //if (totalModifiedProperties.Contains("F_Items"))
            //{
            //    loadDataSB.AppendFormat("{0}.f_loadData();", XID);
            //}
            //else
            //{
            //    loadDataSB.AppendFormat("{0}.store.loadData({1});", XID, F_Items.ToString());
            //}

            //if (totalModifiedProperties.Contains("SelectedValue"))
            //{
            //    loadDataSB.AppendFormat("{0}.f_setValue();", XID);
            //}
            //else
            //{
            //    loadDataSB.AppendFormat("{0}.f_setValue({1});", XID, JsHelper.Enquote(SelectedValue));
            //}
            #endregion

            #endregion
        }