예제 #1
0
        public XrmDateEditor(EditorArguments args)
            : base(args)
        {
            _container = jQuery.FromHtml("<div ><table class='inline-edit-container' cellspacing='0' cellpadding='0'><tr>" +
                "<td><INPUT type=text class='sparkle-input-inline' /></td>" +
                "<td class='lookup-button-td'><input type=button class='sparkle-imagestrip-inlineedit_calendar_icon' /></td></tr></table></div>");
            _container.AppendTo(_args.Container);

            _input = _container.Find(".sparkle-input-inline");
            jQueryObject selectButton = _container.Find(".sparkle-imagestrip-inlineedit_calendar_icon");

            _input.Focus().Select();
            DatePickerOptions options = new DatePickerOptions();
            DatePickerOptions2 options2 = (DatePickerOptions2)(object)options;
            options2.BeforeShow = delegate()
            {
                this._calendarOpen = true;
            };

            options2.OnClose = delegate()
            {
                this._calendarOpen = false;
                _selectedValue = GetSelectedValue();
            };

            if (OrganizationServiceProxy.UserSettings != null)
            {
                _dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
            }

            options.DateFormat = _dateFormat;

            _input.Plugin<DatePickerObject>().DatePicker(options);

            // Wire up the date picker button
            selectButton.Click(delegate(jQueryEvent e){

                _input.Plugin<DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
            });

            //_input.Width(_input.GetWidth() - 24);
        }
        public override void Init(System.Html.Element element, Func<object> valueAccessor, Func<System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context)
        {
            jQueryObject container = jQuery.FromElement(element);
              jQueryObject dateTime = container.Find(".sparkle-input-datepicker-part");
              jQueryObject dateButton = container.Find(".sparkle-input-datepicker-button-part");
                // Add Date Picker
               DatePickerOptions options = new DatePickerOptions();
               options.ShowOn = "";
               options.ButtonImageOnly = true;
               //options.ButtonImage = @"../images/btn_off_Cal.gif";

               string dateFormat = "dd/MM/yy";
               if (OrganizationServiceProxy.UserSettings != null)
               {
                   dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
               }
               options.DateFormat = dateFormat;

               dateTime.Plugin<DatePickerObject>().DatePicker(options);
               //// Get current value
               //Observable<DateTime> dateValueAccessor = (Observable<DateTime>)valueAccessor();
               //DateTime intialValue = dateValueAccessor.GetValue();
               //dateTime.Plugin<DatePickerObject>().DatePicker(DatePickerMethod.SetDate, intialValue);

               dateButton.Click(delegate(jQueryEvent e)
               {
                   // Note: This is using a custom plugin definition since the standard didn't include show
                   dateTime.Plugin<DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
               });

            //handle the field changing
               KnockoutUtils.RegisterEventHandler(dateTime.GetElement(0), "change", delegate(object sender, EventArgs e)
               {
            Observable<DateTime> observable = (Observable<DateTime>)valueAccessor();

            bool isValid = true;

            if (((string)Script.Literal("typeof({0}.IsValid)",observable))!="undefined")
            {
                isValid = ((IValidatedObservable)observable).IsValid() == true;
            }

            if (isValid)
            {
                DateTime selectedDate = (DateTime)dateTime.Plugin<DatePickerObject>().DatePicker(DatePickerMethod.GetDate);
                // Get Current observable value - we only want to set the date part
                DateTime currentValue = observable.GetValue();
                DateTimeEx.SetTime(selectedDate, currentValue);
                observable.SetValue(selectedDate);
            }
            dateTime.Blur();

            });

            Action disposeCallBack =  delegate() {
            Script.Literal("$({0}).datepicker(\"destroy\")",element);
            };

            //handle disposal (if KO removes by the template binding)
            Script.Literal("ko.utils.domNodeDisposal.addDisposeCallback({0}, {1})", element, (object)disposeCallBack);

            //Knockout.BindingHandlers["validationCore"].Init(element, valueAccessor, allBindingsAccessor,null,null);
        }
예제 #3
0
 public static DatePickerObject DatePicker(this jQueryObject q, DatePickerOptions options) {
     return null;
 }
 public DatePickerObject DatePicker(DatePickerOptions options)
 {
     return(null);
 }
 public static DatePickerObject DatePicker(this jQueryObject q, DatePickerOptions options)
 {
     return(null);
 }
예제 #6
0
        private static void SetUpDatePicker(TimeSheetViewModel vm)
        {
            jQueryObject element = jQuery.Select("#datepicker");
            DatePickerOptions options = new DatePickerOptions();
            options.NumberOfMonths = 3;
            options.CalculateWeek = true;

            string dateFormat = "dd/MM/yy";
            if (OrganizationServiceProxy.UserSettings != null)
            {
                dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
            }
            options.DateFormat = dateFormat.Replace("MM", "mm").Replace("yyyy", "yy").Replace("M", "m");

            DatePickerOptions2 options2 = new DatePickerOptions2();
            options2.NumberOfMonths = 3;
            options2.DateFormat = dateFormat.Replace("MM", "mm").Replace("yyyy", "yy").Replace("M", "m");

            // Wire up onSelect event
            options2.OnSelect = delegate(string dateText, object instance)
            {
                // Commit any of the current edits
                EditController controller = sessionsGrid.GetEditController();
                bool editCommited = controller.commitCurrentEdit();
                if (editCommited)
                {
                    DateTime date = (DateTime)element.Plugin<DatePickerObject>().DatePicker(DatePickerMethod.GetDate);
                    vm.SessionDataView.SetCurrentWeek(date);
                }
            };

            element.Plugin<DatePickerPlugIn>().DatePicker(options2);
        }
예제 #7
0
 public DatePickerObject DatePicker(DatePickerOptions options)
 {
     return null;
 }