Results 1 to 4 of 4

Thread: Fun with overrides

  1. #1
    Sencha Premium Member
    Join Date
    Nov 2013
    Posts
    16
    Answers
    3

    Default Answered: Fun with overrides

    Hi all;


    I am trying to set a default for all of my forms that whenever I have a required form field I show a red asterisk between the label and the form component. After some searching on how to accomplish this, I went down the path of creating an override for the FormLayout class (adding it to my overrides folder), and found some code that would accomplish this using a <span> tag. I am currently using Sencha Architect 3 (and notepad++ to create the override). here is what I am getting back when I try to build or refresh the application:

    Code:
    \ext-theme-classic\src
    [INF] Loading classpath entry C:\Users\Ian\Documents\Sencha\BaseUI\ext\packages\ext-theme-classic\overrides
    [INF] Loading classpath entry C:\Users\Ian\Documents\Sencha\BaseUI\overrides
    [INF] Loading classpath entry C:\Users\Ian\Documents\Sencha\BaseUI\app
    [INF] Loading classpath entry C:\Users\Ian\Documents\Sencha\BaseUI\app.js
    [INF] Loading classpath entry C:\Users\Ian\Documents\Sencha\BaseUI\build\temp\testing\BaseUI\sencha-compiler\app
    [ERR] C2008: Requirement had no matching files (FormLayout.js) -- C:\Users\Ian\Documents\Sencha\BaseUI\app.js:25:10
    [ERR] 
    [ERR] BUILD FAILED
    [ERR] com.sencha.exceptions.ExBuild: Failed to find any files for C:\Users\Ian\Documents\Sencha\BaseUI\app.js::ClassRequire::FormLayout.js
    [ERR] 
    [ERR] Total time: 4 seconds
    [ERR] The following error occurred while executing this line:
    C:\Users\Ian\Documents\Sencha\BaseUI\.sencha\app\build-impl.xml:367: The following error occurred while executing this line:
    C:\Users\Ian\Documents\Sencha\BaseUI\.sencha\app\js-impl.xml:11: com.sencha.exceptions.ExBuild: Failed to find any files for C:\Users\Ian\Documents\Sencha\BaseUI\app.js::ClassRequire::FormLayout.js
    I have added a reference to the overrides folder in my sencha.cfg:

    Code:
    ...
    # The path(s) to application javascript sources (comma separated)
    app.classpath=${app.dir}/app,${app.dir}/app.js,${app.dir}/overrides
    ...
    and I have added the appropriate 'requires:' statement to my app.js"
    Code:
    // @require @packageOverrides
    Ext.Loader.setConfig({
        enabled: true
    });
    Ext.application({
    requires: [
            'FormLayout.js'
        ],
        models:  
        ...
    Below is my override (FormLayout.js which is in my overrides folder):

    Code:
    Ext.define('BaseUI.overrides.FormLayout', {  
        override: 'Ext.layout.FormLayout',  
        getTemplateArgs: function(field) {
                var noLabelSep = !field.fieldLabel || field.hideLabel;
                var labelSep = (typeof field.labelSeparator == 'undefined' ? this.labelSeparator : field.labelSeparator);
                if (field.required) labelSep += '<span style="color: rgb(255, 0, 0); padding-left: 2px;">*</span>';
                return {
                    id: field.id,
                    label: field.fieldLabel,
                    labelStyle: field.labelStyle||this.labelStyle||'',
                    elementStyle: this.elementStyle||'',
                    labelSeparator: noLabelSep ? '' : labelSep,
                    itemCls: (field.itemCls||this.container.itemCls||'') + (field.hideLabel ? ' x-hide-label' : ''),
                    clearCls: field.clearCls || 'x-form-clear-left'
                };
            }
      
    });
    Is there a better way to accomplish what I am trying to do? or a way to make this work?

    Thanks

    Ian

  2. Thanks Jminnick - - you set me on the right path. the requires statement in app.js was expecting a class not a file name

    rookie mistake

  3. #2
    Sencha User
    Join Date
    Jan 2009
    Location
    Frederick, Maryland
    Posts
    925
    Answers
    66

    Default

    If the name of your app is BaseUI it is going to map to the app directory which is a sibling to overrides. So that path will likely not be correct.

    I can't see your whole project so that is just a guess.

  4. #3
    Sencha Premium Member
    Join Date
    Nov 2013
    Posts
    16
    Answers
    3

    Default

    Thanks Jminnick - - you set me on the right path. the requires statement in app.js was expecting a class not a file name

    rookie mistake

  5. #4
    Sencha Premium Member
    Join Date
    Oct 2013
    Posts
    46
    Answers
    3

    Default

    Hey guys, having a similar issue..not sure what I'm missing but my override is not being used:

    1. Defined overrides folder in sencha.cfg:

    # The path(s) to application javascript sources (comma separated)
    app.classpath=${app.dir}/app,${app.dir}/app.js,${app.dir}/overrides

    2. Created Override File in overrides/view/Table.js

    Screen Shot 2014-01-05 at 9.45.21 PM.png

    Code:
    Ext.override('Ext.view.Table', { 
      getRowStyleTableElOriginal: 'Ext.view.Table.prototype.getRowStyleTableEl', 
      getRowStyleTableEl: function() { 
        console.log('in this function');
        var el = this.getRowStyleTableElOriginal.apply(this, arguments); 
        if (!el) { 
          el = { 
            addCls: Ext.emptyFn, 
            removeCls: Ext.emptyFn, 
            tagName: {} 
          }; 
        } 
        return el; 
      } 
    });
    Do I need to add something in the requires array?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •