Search code examples
javascriptextjssencha-touch-2sencha-cmd

Strange behavior after the production build with Sencha project


I am having a strange behavior after the production build with Sencha CMD. My development running on localhost is working correctly, but after the build the searchfield is not working, everything is ok, except this component. I have tested all, but I don´t have any clue about this issue.

Problem is in this code

/* On Key Up of Search Partners*/
onSearchPartnersKeyUp: function (searchField, pressed) {
    var queryString = searchField.getValue();
    var store = Ext.getStore('Partners');
    store.clearFilter();
    pressed = this.getPartnerSegment().getPressedButtons(); //get reference to the segmentedButton
    var contacttype = pressed[0].contactTypeBtn;
    if (queryString && queryString.length > 2) {
        var thisRegEx = new RegExp(queryString, "i");
        store.filterBy(function (record) {
            if ((thisRegEx.test(record.get('id')) || thisRegEx.test(record.get('name')))
                && ((record.get('contacttype') == contacttype)
                || (pressed[0].getItemId() == 'showAllPartners'))) {
                this.getPartnerList().getScrollable().getScroller().scrollTo(0, 0);
                return true;
            }

            return false;
        }, this);
    }

    store.filter('contacttype', contacttype);

},

Maybe, in the second "if", when sencha cmd minimize has any confusion..??¿?¿

In the view I have this code:

items        : [
                        {
                            xtype      : 'typeButton',
                            itemId     : 'showOnlyPartners',
                            contactTypeBtn: 'CU',
                            iconCls    : 'user',
                            iconMask   : true,
                            text       : Cicero.Text.getText('P_BTN_PARTNERS')
                        },
                        {
                            xtype      : 'typeButton',
                            itemId     : 'showOnlyOutlets',
                            contactTypeBtn: 'OU',
                            iconCls    : 'outlet',
                            iconMask   : true,
                            text       : Cicero.Text.getText('P_BTN_OUTLETS')
                        },
                        {
                            xtype      : 'typeButton',
                            itemId     : 'showAllPartners',
                            contactTypeBtn: '',
                            pressed    : true,
                            text       : Cicero.Text.getText('P_BTN_ALL')
                        }
                    ]

Thank you in advance.


Solution

  • Solved, the problem was:

    contactTypeBtn is not a Sencha´s property, in my localhost doesn´t care and it is working correctly but after the build, Sencha needs to find this "property" and of course Sencha doesn´t find it.. The solution was overwriting button class adding this property.

    For instance:

    Ext.define('xr.utility.TypeButton', {
       extend: 'Ext.Button',
       xtype : 'typeButton',
    
       config: {
        contactTypeBtn: ''
       }
    });
    

    It was a very tricky issue.