Results 1 to 6 of 6

Thread: Editing Code in Code View

  1. #1
    Ext JS Premium Member
    Join Date
    Nov 2010
    Posts
    82

    Exclamation Editing Code in Code View

    I know this question must have been asked before. But I'll ask again and if someone can point me to a thread that answered this quetsion, that'd be great.

    I'm using Sencha Architect 2.0.0 and created some UI components in Design view.
    However, I noticed that the code view is readonly - which makes sense most of the time.

    But I need to define a global variable (an array) that will be used across several grids. I want to write code for a global variable at the application level. How can i do this in Architect? Or do I need to export the code, and modify the code outside?

    Please provide some guidance.

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Posts
    350

    Default

    Define it in Application launch function. You can add this function from Application node.
    Bharat Nagwani
    Sencha Designer Development Team

  3. #3
    Ext JS Premium Member
    Join Date
    Nov 2010
    Posts
    82

    Default

    Ok, when I put this in application launch, i see red indicators saying "Mixed spaces and tabs".

    Code:
        var colorarray=['#49ADD6',
                        '#EFBC58',
                        '#0066BA',
                        '#CC6600',
                        '#76B868',
                        '#A471A8',
                        '#FADC85',
                        '#AB2529',
                        '#BFBFBF',
                        '#D2E8B5',
                        '#6B95B4',
                        '#DA3F13',
                        '#192F47',
                        '#009933',
                        '#BE3163',
                        '#E3E3E3',
                        '#84C4C2',
                        '#A16937',
                        '#D6CFF5',
                        '#C2AF8E'];
    Do I need to put everything on a single line?

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    350

    Default

    You can ignore that warning. Though you should just use spaces or tabs.

    Talking about global variables use application namespace so you not creating local variables.

    Code:
    MyApp.global = {}; 
    MyApp.global.vara =['#49ADD6',
                       '#EFBC58',
                       '#0066BA',
                       '#CC6600',
                       '#76B868',
                       '#A471A8',
                       '#FADC85',
                       '#AB2529',
                       '#BFBFBF',
                       '#D2E8B5',
                       '#6B95B4',
                       '#DA3F13',
                       '#192F47',
                       '#009933',
                       '#BE3163',
                       '#E3E3E3',
                       '#84C4C2',
                       '#A16937',
                       '#D6CFF5',
                       '#C2AF8E'];
    Bharat Nagwani
    Sencha Designer Development Team

  5. #5
    Ext JS Premium Member
    Join Date
    Nov 2010
    Posts
    82

    Default

    Ok, so none of your suggestions worked.
    1) I added launch

    Code:
    launch: function() {
    var colorarray=['#49ADD6','#EFBC58','#0066BA','#CC6600','#76B868','#A471A8','#FADC85','#AB2529','#BFBFBF','#D2E8B5','#6B95B4','#DA3F13','#192F47','#009933','#BE3163','#E3E3E3','#84C4C2','#A16937','#D6CFF5','#C2AF8E'];
    }
    2) Then I tried this:
    Code:
    launch: function() {
    MyApp.global = {};
    MyApp.global.colorarray=['#49ADD6','#EFBC58','#0066BA','#CC6600','#76B868','#A471A8','#FADC85','#AB2529','#BFBFBF','#D2E8B5','#6B95B4','#DA3F13','#192F47','#009933','#BE3163','#E3E3E3','#84C4C2','#A16937','#D6CFF5','#C2AF8E'];
    }
    None of these worked, meaning in a GridPanel, I have a renderer for a 'gridcolumn, and when I try it out in a browser, it says colorarray undefined.

    This is my renderer code:

    Code:
     renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
                                    if(record.data.dataItemName != 'Total') {
                                        return '<div style="background-color:'+colorarray[rowIndex]+';height:15px;width:15px;"></div>';
                                    }
                                }

  6. #6
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488

    Default

    You'd need to access it from where you put it... change colorarray in your renderer to MyApp.global.colorarray.
    Aaron Conran
    @aconran

Posting Permissions

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