コード例 #1
0
        protected override string ToJSSettings()
        {
            string jsScript = base.ToJSSettings();

            if (!jsScript.EndsWith(","))
            {
                jsScript += ",";
            }
            if (!ARIATemplate.IsNullOrWhiteSpace())
            {
                jsScript += "ARIATemplate:'" + ARIATemplate + "'";
            }
            if (Depth.HasValue)
            {
                jsScript = AddOptions(jsScript, string.Format("start:'{0}',depth:'{1}'",
                                                              Depth.Value.ToString().LowercaseFirst(),
                                                              Depth.Value.ToString().LowercaseFirst()));
            }
            if (Max.HasValue)
            {
                jsScript = AddOptions(jsScript, string.Format("max:new Date({0},{1},{2})",
                                                              Max.Value.Year, Max.Value.Month - 1, Max.Value.Day));
            }
            if (Min.HasValue)
            {
                jsScript = AddOptions(jsScript, string.Format("min:new Date({0},{1},{2})",
                                                              Min.Value.Year, Min.Value.Month - 1, Min.Value.Day));
            }
            if (Value.HasValue)
            {
                jsScript = AddOptions(jsScript, string.Format("value:new Date({0},{1},{2})",
                                                              Value.Value.Year, Value.Value.Month - 1, Value.Value.Day));
            }

            return(jsScript);
        }
コード例 #2
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var options = new Dictionary <string, object>(Events);

            var idPrefix = "#";

            if (IsInClientTemplate)
            {
                idPrefix = "\\" + idPrefix;
            }

            var animation = Animation.ToJson();

            if (animation.Keys.Any())
            {
                options["animation"] = animation["animation"];
            }

            if (ARIATemplate.HasValue())
            {
                options["ARIATemplate"] = ARIATemplate;
            }

            if (Culture.HasValue())
            {
                options["culture"] = Culture;
            }

            options["format"] = Format;

            if (ParseFormats.Any())
            {
                options["parseFormats"] = ParseFormats;
            }

            options["min"] = Min;
            options["max"] = Max;

            if (EnableFooter)
            {
                if (FooterId.HasValue())
                {
                    options["footer"] = new ClientHandlerDescriptor {
                        HandlerName = string.Format("$('{0}{1}').html()", idPrefix, FooterId)
                    };
                }
                else if (Footer.HasValue())
                {
                    options["footer"] = Footer;
                }
            }
            else
            {
                options["footer"] = EnableFooter;
            }

            if (Depth.HasValue())
            {
                options["depth"] = Depth;
            }

            if (Start.HasValue())
            {
                options["start"] = Start;
            }

            MonthTemplate.IdPrefix = idPrefix;

            var month = MonthTemplate.ToJson();

            if (month.Keys.Any())
            {
                options["month"] = month;
            }

            if (Dates.Any())
            {
                options["dates"] = Dates;
            }

            writer.Write(Initializer.Initialize(Selector, "DatePicker", options));

            base.WriteInitializationScript(writer);
        }