[CLOSED] MonthPicker and MonthField

Page 2 of 2 FirstFirst 12
  1. #11
    Daniil i would to suggest the first date of the month (default behaviour when day is shown). For me it sounds strange to save a month / year date and it saves, as example, 12/29/2014.
    Last edited by RCN; Dec 29, 2014 at 6:40 AM.
  2. #12
    Do you mean that you would like to see your override to be incorporated to Ext.NET?
    Ext.form.field.Date.override({
        safeParse: function (value, format) {
            var result = this.callParent(arguments);
            if (this.type == "month") {
                return Ext.Date.getFirstDateOfMonth(result);
            }
            return result;
        }
    });
  3. #13
    Yes. But please let review it to be sure that it's 100% correct, i mean, that there is no resulting issue by doing that and that is the best approach.

    In next few hours i come up with the results, ok?
  4. #14
    Sure, no problem. I think there is no need in rush.
  5. #15
    It's necessary to validate if result is not null because if user type a invalid "month / year", result will equal null, and an exception will be throw at line 5
    Ext.form.field.Date.override({
        safeParse: function (value, format) {
            var result = this.callParent(arguments);
            if (result != null && this.type == "month") {
                return Ext.Date.getFirstDateOfMonth(result);
            }
            return result;
        }
    });
    Daniil, i noticed that safeParse is called 6 times when a date is selected. I think that this could be optimized?.



    Going further, if you type a invalid month / year, and then click on trigger, safeParse is called hundreds times.

    So, i would set that the field is not editable if type equals month, which prevents the issue presented above.
    Ext.form.field.Date.override({
        initComponent : function(){
            this.callParent(arguments);
            if (this.type == "month") {
                this.editable = false;
            }
        },
        safeParse: function (value, format) {
            var result = this.callParent(arguments);
            if (result != null && this.type == "month") {
                return Ext.Date.getFirstDateOfMonth(result);
            }
            return result;
        }
    });
    Last edited by RCN; Dec 29, 2014 at 4:30 PM.
  6. #16
    Raphael, thank you for sharing your findings. I will be investigating this in the next year.
  7. #17
    @RCN,
    Does the call to this.callParent inside safeParse cause the function to recursively call itself until a value/format match is found?

    --

    As far as I can understand the problem is with the day returned by the field when mode is set to month. Even though I agree with Daniil that the day should be ignored in this case it can't harm getting the first date of the selected month/year as a result. If restricting keyboard input is too limiting and overriding the safeParse function is inefficient (and not 100% solid, probably) then why not just apply the getFirstDateOfMonth to the date returned by the field?

    var analyze = function () {
        alert(Ext.Date.getFirstDateOfMonth(App._dt.getValue()));
    }
    Last edited by Dimitris; Jan 28, 2015 at 6:17 PM.
  8. #18
    Raphael, do you mind if we close this thread?

    A new thread about the month picker's selection bug with certain locales will be created in the Bugs forum.
  9. #19
    Raphael, do you mind if we close this thread?
    No Dimitris, go ahead.

    A new thread about the month picker's selection bug with certain locales will be created in the Bugs forum.
    I think that it's good to make a cross-reference, if you agree of course.


    Once again, thank you all.
  10. #20
    MonthPicker locale specific issue moved to Bugs:
    http://forums.ext.net/showthread.php...561#post240561

    Related issue opened.
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 13
    Last Post: Apr 27, 2016, 1:44 AM
  2. Replies: 5
    Last Post: Aug 13, 2013, 3:52 PM
  3. [CLOSED] Can't resolve the ext:MonthPicker
    By KevinWinter in forum 2.x Help
    Replies: 2
    Last Post: Aug 13, 2013, 8:35 AM
  4. Download MonthPicker Plugins
    By initial_b in forum 1.x Help
    Replies: 0
    Last Post: Aug 18, 2011, 11:12 AM
  5. [CLOSED] [1.0] DateField MonthPicker with daterange
    By MP in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 08, 2010, 10:25 PM

Posting Permissions