Inheritance: SparkleXrm.GridEditor.GridEditorBase
Example #1
0
        public XrmDateEditor(EditorArguments args) : base(args)
        {
            XrmDateEditor self = this;

            _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");
            _input.Bind("keydown.nav", delegate(jQueryEvent e)
            {
                if (!_calendarOpen && (e.Which == 38 || e.Which == 40) && e.CtrlKey) // Ctrl-Up/Down shows date picker
                {
                    _input.Plugin <DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
                    e.StopImmediatePropagation();
                }
                else if (_calendarOpen && e.Which == 13)
                {
                    e.PreventDefault();
                }
            });
            jQueryObject selectButton = _container.Find(".sparkle-imagestrip-inlineedit_calendar_icon");

            _input.Focus().Select();
            DatePickerOptions2 options2 = new DatePickerOptions2();

            options2.ShowOtherMonths = true;
            options2.ShowOn          = ""; // Date Pickers in CRM do not show when they are focused - you click the button
            options2.FirstDay        = OrganizationServiceProxy.OrganizationSettings != null ? OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value : 0;
            options2.BeforeShow      = delegate()
            {
                this._calendarOpen = true;
            };

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

            options2.OnSelect = delegate(string dateString, object instance)
            {
                // Select the date text field when selecting a date
                Focus();
            };

            if (OrganizationServiceProxy.UserSettings != null)
            {
                _dateFormat = OrganizationServiceProxy.UserSettings.DateFormatString;
            }
            options2.DateFormat = _dateFormat;
            _input.Plugin <DatePickerPlugIn>().DatePicker(options2);

            // Wire up the date picker button
            selectButton.Click(delegate(jQueryEvent e){
                _input.Plugin <DatePickerPlugIn>().DatePicker(DatePickerMethod2.Show);
                Focus();
            });
        }
Example #2
0
 static XrmDateEditor()
 {
     CrmDateEditor = delegate(EditorArguments args)
     {
         XrmDateEditor editor = new XrmDateEditor(args);
         return editor;
     };
 }
Example #3
0
 static XrmDateEditor()
 {
     CrmDateEditor = delegate(EditorArguments args)
     {
         XrmDateEditor editor = new XrmDateEditor(args);
         return(editor);
     };
 }