1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    123
    Vote Rating
    2
    denisputnam is on a distinguished road

      0  

    Default How do I create a class scoped variable for a controller in Architect?

    How do I create a class scoped variable for a controller in Architect?


    I need to keep track of which record index gets selected in a grid in order to mark a the same record associated with a form as dirty so my controller knows to sync the record to the store. Where can I create a variable to store the index in the controller so I can mark the correct record in Architect 2?

    Code:
    Ext.define('MySchool.controller.SubjectsController', {    extend: 'Ext.app.Controller',
    
    
        models: [
            'SubjectsModel'
        ],
        stores: [
            'SubjectStore'
        ],
        views: [
            'MainPanel',
            'SubjectsGridPanel',
            'SubjectsForm',
            'SubjectsPanel'
        ],
    
    
        refs: [
            {
                ref: 'subjectsForm',
                selector: 'form'
            }
        ],
    
    
        constructor: function(cfg) {
            cfg = cfg || {};
            this.callParent(this.processSubjectsController(cfg));
        },
    
    
        processSubjectsController: function(config) {
            return config;
        },
    
    
        onSubjectsgridSelect: function(rowmodel, record, index, eOpts) {
            window.console.log( "selected row in grid." );
            window.console.log( "index=" + index );
            //debugger;
            if ( record ) {
                this.getSubjectsForm().getForm().loadRecord(record);
            }
        },
    
    
        onSubjectdescriptiontextareaChange: function(field, newValue, oldValue, eOpts) {
            // NEED TO MARK THE GRID's RECORD DIRTY HERE BUT I DON'T HOW TO GET A HOLD OF THE RECORD INDEX OR THE RECORD.
        },
    
    
        onSubjectobjectivetextareaChange: function(field, newValue, oldValue, eOpts) {
            // NEED TO MARK THE GRID's RECORD DIRTY HERE BUT I DON'T HOW TO GET A HOLD OF THE RECORD INDEX OR THE RECORD.
        },
    
    
        init: function(application) {
    
    
            this.control({
                'subjectsgridpanel': {
                    selectionchange: this.gridSelectionChange,
                    viewready: this.onViewReady
                },
                'subjectsavetool': {
                    click: this.onSubjectsavetoolidClick
                }
            });
    
    
    
    
            this.control({
                "#subjectsgrid": {
                    select: this.onSubjectsgridSelect
                },
                "#subjectdescriptiontextarea": {
                    change: this.onSubjectdescriptiontextareaChange
                },
                "#subjectobjectivetextarea": {
                    change: this.onSubjectobjectivetextareaChange
                }
            });
        },
    
    
        gridSelectionChange: function(model, records) {
    
    
            if ( records[0] ) {
                this.getSubjectsForm().getForm().loadRecord(records[0]);
            }
        },
    
    
        onViewReady: function(grid) {
    
    
            grid.getSelectionModel().select( 0 );
        },
    
    
        onSubjectsavetoolidClick: function(tool, e, eOpts) {
            window.console.log( "Save..." );
            //debugger;
    
    
            var mystore = Ext.getStore("SubjectStore");
    
    
            var records = mystore.getModifiedRecords();
            for( var i = 0; i < records.length; i++ )
            {
                records[i].set( 'lastUpdated', new Date() );
                var form = Ext.getCmp( 'subjectdetailsform' );
                var formValues = form.getValues();
                records[i].set( 'description', formValues.description );
                records[i].set( 'objectives', formValues.objectives );
                window.console.log( 'objectives=' + formValues.objectives );
                window.console.log( 'description=' + formValues.description );
            }
    
    
            mystore.sync();
            //mystore.commmitChanges();
    
    
            // Last but not least, I can do this (Approach #3)
            //Ext.app.Application.fireEvent("saveSubjects", tool );
        }
    
    
    });

  2. #2
    Sencha User
    Join Date
    Apr 2011
    Posts
    123
    Vote Rating
    2
    denisputnam is on a distinguished road

      0  

    Default


    Never mind. I see that you can add it in the Config window of the Architect IDE.

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