lundi 7 juillet 2014

Date filter convertValue method issue



  1. Thank you for reporting this bug. We will make it our priority to review this report.







  2. Default Date filter convertValue method issue



    Date filter convertValue method issue





    Hi,

    Trying to migrate from the old UX based filters to the new plugins.

    Having trouble getting date filters working.


    The first issue is that convertValue does not do what the function header implies.

    It returns a boolean at times.


    My fix:



    Code:



    /**
    * @private
    * Will convert a timestamp to a Date object or vice-versa.
    * @param {Date/Number} value
    * @param {Boolean} [convertToDate]
    * @return {Date/Number}
    */
    convertValue: function (value, convertToDate) {
    if (convertToDate && !Ext.isDate(value)) {
    value = new Date(value);
    } else if (!convertToDate && Ext.isDate(value)) {
    value = (+value);
    }


    return value;
    }

    The first block was setting the value to Ext.isDate(value).

    Would be surprised if this has been tested at all to be honest.

    The issue I am currently fighting is the fact that the dateFormat is completely ignored.

    When the filter is serialised the value is set to the numeric date value, which is no use.

    Hope to find a fix for that soon.


    Can I suggest you do some testing of these filters perhaps?


    Cheers,

    Westy














  3. Default







    Believe have found another part of the puzzle.

    It's probably another issue, but related so will put here.

    Convert needs to not convert to a number, it needs to use the dateFormat.


    So:



    Code:



    /**
    * @private
    * Will convert a timestamp to a Date object or vice-versa.
    * @param {Date/String} value
    * @param {Boolean} [convertToDate]
    * @return {Date/String}
    */
    convertValue: function (value, convertToDate) {
    if (convertToDate && !Ext.isDate(value)) {
    value = new Date(value);
    } else if (!convertToDate && Ext.isDate(value)) {
    value = Ext.Date.format(value, this.dateFormat);
    }


    return value;
    }

    Cheers,

    Westy












Aucun commentaire:

Enregistrer un commentaire