1. #1
    Sencha Premium Member sencha-dev2's Avatar
    Join Date
    Jun 2012
    Location
    France
    Posts
    59
    Answers
    2
    Vote Rating
    0
    sencha-dev2 is on a distinguished road

      0  

    Question Unanswered: setValue() on datefield doesn't work as expected

    Unanswered: setValue() on datefield doesn't work as expected


    Hi,

    I have to make a grid which refreshes data and column headers by buttons and date-picking.

    For the date-picking part, function works fine, but for the button one, the headers don't refresh and the value in the field stays the same. Can somebody help me ? Here's the function on the button for the previous week :

    Code:
    onBtnSMoinsClick: function(button, e, options) {
        var date = Ext.ComponentQuery.query('datefield[itemId="dateS"]')[0];
        console.log(date.getValue());
        date.setValue(new Date(date.value.getFullYear(), date.value.getMonth(), (parseInt(date.value.getDate(), 10) - 7)));
        console.log(date.getValue());
        date.fireEvent('select', date, date.getValue());
    }
    And here is the select event fired :

    Code:
    onDatefieldSelect: function(field, value, options) {
        var headerL = field.up().up().down('gridcolumn[dataIndex="plateauxLundi"]'),
        headerM = field.up().up().down('gridcolumn[dataIndex="plateauxMardi"]'),
        headerMe = field.up().up().down('gridcolumn[dataIndex="plateauxMercredi"]'),
        headerJ = field.up().up().down('gridcolumn[dataIndex="plateauxJeudi"]'),
        headerV = field.up().up().down('gridcolumn[dataIndex="plateauxVendredi"]'),
        headerS = field.up().up().down('gridcolumn[dataIndex="plateauxSamedi"]'),
        headerD = field.up().up().down('gridcolumn[dataIndex="plateauxDimanche"]'),
        head = [headerL, headerM, headerMe, headerJ, headerV, headerS, headerD],
        jour,
        mois,
        dt = new Date(value);
    
    
        // récupération du jour sélectionné (/mois)
        var jourMois = dt.getDate();
        // récupération de l'indice du jour dans la semaine
        var jourSemaine = dt.getDay();
        // création d'une date commençant au lundi de la semaine
        if(jourSemaine === 0 || jourSemaine === '0') {
            jour = jourMois - 7;
        } else {
            jour = jourMois - jourSemaine + 1;
        }
        // affectation des dates aux headers
        for(var i = 0; i < 7; i++) {
            var m = 1;
            var d = jour + i;
            if(dt.getMonth() === 1 || dt.getMonth() === '1') {
                if(dt.isLeapYear() && d > 29) {
                    d = d - 29;
                    m = 2;
                } else {
                    if(d > 28) {
                        d = d - 28;
                        m = 2;
                    }
                 }
            } else {
                if((dt.getMonth() === 3 || dt.getMonth() === '3' || dt.getMonth() === 5 || dt.getMonth() === '5' || dt.getMonth() === 8 || dt.getMonth() === '8' || dt.getMonth() === 10 || dt.getMonth() === '10') && d > 30) {
                    d = d - 30;
                    m = 2;
                } else {
                    if(d > 31) {
                        d = d - 31;
                        m = 2;
                    }
                }
            }
            if(dt.getMonth() + m > 12) {
                mois = '01';
            } else {
                mois = (((dt.getMonth() + m) < 10) ? ('0' + (dt.getMonth() + m)) : (dt.getMonth() + m));
            }
            head[i].setText(head[i].text.split(' ')[0] + ' ' + d + '/' + mois);
        }
        
        
        Ext.ComponentQuery.query('gridpanel[itemId="grid"]')[0].store.filterBy(function(record) {
            var date = record.get('date').split('/');
            var semaine = new Date(date[2], (parseInt(date[1]) - 1), date[0]);
            semaine = Ext.Date.format(semaine, 'W');
            var s = field.getRawValue().split('/')[0];
            if(semaine === s) return true;
        });
    }
    The previous one works fine on every call I do, except for the button one.
    Here's the beforerender event I use on the datefield, which also calls the function above :

    Code:
    onDatefieldBeforerender: function(abstractcomponent, options) {
        abstractcomponent.setValue(new Date());
        abstractcomponent.fireEvent('select', abstractcomponent, abstractcomponent.getValue());
    }
    Hope you'll understand why it doesn't work especially for the button... Thanks in advance.

    [EDIT]

    Moreover, it totally blocks me on my work as it is the last point I must get to-work before I can change of subject... So please, help me.
    Last edited by sencha-dev2; 26 Dec 2012 at 12:10 AM. Reason: It is quite urgent for me...

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,731
    Answers
    3362
    Vote Rating
    754
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What do you mean by "but for the button one" which is what I read doesn't work correct?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member sencha-dev2's Avatar
    Join Date
    Jun 2012
    Location
    France
    Posts
    59
    Answers
    2
    Vote Rating
    0
    sencha-dev2 is on a distinguished road

      0  

    Default


    Forgive me, I haven't been clear, I meant that every call I make to the function from the button click event doesn't work. Every other call from any other source works well...

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar