Пример #1
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            //// 日期选择器也需要菜单组件的支持
            //ResourceManager.Instance.AddJavaScriptComponent("menu");

            // extjs 的日期格式化字符串
            string extjsDateFormatString = ExtDateTimeConvertor.ConvertToExtDateFormat(DateFormatString);

            OB.AddProperty("format", extjsDateFormatString);

            if (EnableChineseAltFormats)
            {
                OB.AddProperty("altFormats", "Y-m-d|Y-n-j|Ymd|Ynj|y-m-d|y-n-j|ymd|ynj");
            }
            else if (AltFormats != null)
            {
                StringBuilder formats = new StringBuilder();
                foreach (string format in AltFormats)
                {
                    formats.Append(ExtDateTimeConvertor.ConvertToExtDateFormat(format));
                    formats.Append("|");
                }
                OB.AddProperty("altFormats", formats.ToString().TrimEnd('|'));
            }

            //// 当前选中的日期值,这个在父类中已经设置了
            //OB.RemoveProperty(OptionName.Value);
            //if (SelectedDate != null) OB.AddProperty(OptionName.Value, Text);

            if (MaxDate != null)
            {
                OB.AddProperty("maxValue", MaxDate.Value.ToString(DateFormatString));
            }
            if (MinDate != null)
            {
                OB.AddProperty("minValue", MinDate.Value.ToString(DateFormatString));
            }

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


            if (EnableDateSelectEvent)
            {
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(GetPostBackEventReference("Select")), true);
            }

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

            AddStartupScript(jsContent);
        }
Пример #2
0
        /// <summary>
        /// 渲染 HTML 之前调用(AJAX回发)
        /// </summary>
        protected override void OnAjaxPreRender()
        {
            base.OnAjaxPreRender();

            StringBuilder sb = new StringBuilder();

            if (PropertyModified("SelectedDate"))
            {
                sb.AppendFormat("{0}.setValue({1});", XID, ExtDateTimeConvertor.GetExtDateObject(SelectedDate.Value));
            }

            AddAjaxScript(sb);
        }
Пример #3
0
        private string GetRenderer()
        {
            if (!String.IsNullOrEmpty(RendererFunction))
            {
                return(RendererFunction);
            }

            if (Renderer == Renderer.None)
            {
                return(String.Empty);
            }

            if (Renderer == Renderer.Date)
            {
                string argument = "yyyy-MM-dd";
                if (!String.IsNullOrEmpty(RendererArgument))
                {
                    argument = RendererArgument;
                }
                return(String.Format("X.format.date('{0}')", ExtDateTimeConvertor.ConvertToExtDateFormat(argument)));
            }
            else if (Renderer == Renderer.Ellipsis)
            {
                string argument = "10";
                if (!String.IsNullOrEmpty(RendererArgument))
                {
                    argument = RendererArgument;
                }
                return(String.Format("X.format.ellipsis({0})", argument));
            }
            else if (Renderer == Renderer.Number)
            {
                string argument = "0.00";
                if (!String.IsNullOrEmpty(RendererArgument))
                {
                    argument = RendererArgument;
                }
                return(String.Format("X.format.number('{0}')", argument));
            }
            else
            {
                return(String.Format("X.format.{0}", RendererName.GetName(Renderer)));
            }
        }
Пример #4
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            // extjs 的日期格式化字符串
            string extjsDateFormatString = ExtDateTimeConvertor.ConvertToExtDateFormat(DateFormatString);

            OB.AddProperty("format", extjsDateFormatString);

            //if (EnableChineseAltFormats)
            //{
            //    OB.AddProperty("altFormats", "Y-m-d|Y-n-j|Ymd|Ynj|y-m-d|y-n-j|ymd|ynj");
            //}

            if (SelectedDate != null)
            {
                OB.AddProperty("value", ExtDateTimeConvertor.GetExtDateObject(SelectedDate.Value), true);
            }

            if (MaxDate != null)
            {
                OB.AddProperty("maxDate", ExtDateTimeConvertor.GetExtDateObject(MaxDate.Value), true);
            }

            if (MinDate != null)
            {
                OB.AddProperty("minDate", ExtDateTimeConvertor.GetExtDateObject(MinDate.Value), true);
            }


            if (EnableDateSelectEvent)
            {
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(GetPostBackEventReference("Select")), true);
            }


            string jsContent = String.Format("var {0}=Ext.create('Ext.picker.Date',{1});", XID, OB.ToString());

            AddStartupScript(jsContent);
        }
Пример #5
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            //// 日期选择器也需要菜单组件的支持
            //ResourceManager.Instance.AddJavaScriptComponent("menu");

            // extjs 的日期格式化字符串
            string extjsDateFormatString = ExtDateTimeConvertor.ConvertToExtDateFormat(TimeFormatString);

            OB.AddProperty("format", extjsDateFormatString);

            if (AltFormats != null)
            {
                StringBuilder formats = new StringBuilder();
                foreach (string format in AltFormats)
                {
                    formats.Append(ExtDateTimeConvertor.ConvertToExtDateFormat(format));
                    formats.Append("|");
                }
                OB.AddProperty("altFormats", formats.ToString().TrimEnd('|'));
            }

            if (Increment != INCREMENT_DEFAULT)
            {
                OB.AddProperty("increment", Increment);
            }


            ////// 当前选中的日期值,这个在父类中已经设置了
            ////OB.RemoveProperty(OptionName.Value);
            ////if (SelectedDate != null) OB.AddProperty(OptionName.Value, Text);


            if (MaxTime.HasValue)
            {
                OB.AddProperty("maxValue", MaxTime.Value.ToString(TimeFormatString));
            }
            else if (!String.IsNullOrEmpty(MaxTimeText))
            {
                OB.AddProperty("maxValue", MaxTimeText);
            }

            if (MinTime.HasValue)
            {
                OB.AddProperty("minValue", MinTime.Value.ToString(TimeFormatString));
            }
            else if (!String.IsNullOrEmpty(MinTimeText))
            {
                OB.AddProperty("minValue", MinTimeText);
            }


            if (EnableTimeSelect)
            {
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(GetPostBackEventReference("Select")), true);
            }


            string jsContent = String.Format("var {0}=new Ext.form.TimeField({1});", XID, OB.ToString());

            AddStartupScript(jsContent);
        }