Странная ошибка this.grid - неопределенный ext-all-debug.js - PullRequest
2 голосов
/ 30 октября 2011

У меня есть сетка редактора

Grid.Selection = Ext.extend(Ext.grid.EditorGridPanel, {
layout:'fit',
border:false,
stateful:false,

initComponent: function() {        

    Ext.apply(this, {
        // {{{
        store: new Ext.data.SimpleStore({
            id: 0,
            fields: [ ...],
            data: []
        })
        ,cm: new Ext.grid.ColumnModel({
            // specify any defaults for each column
            defaults: {
                sortable: true // columns are not sortable by default           
            },
            columns: [
                rowNumberer, 
                combo1,
                combo2,
                combo3,
                itemDeleter]
        })
        // }}}
        ,plugins: new Ext.ux.plugins.GridValidator()
        ,viewConfig: {forceFit: true}
        ,sm: itemDeleter
        ,height: 150
        ,frame: true
        ,clicksToEdit: 1
        ,tbar: [{
                text: 'Add New Association'
                ,id: 'addBtnGrid'
                ,iconCls: 'icon-plus'                    
                ,listeners: {
                    click: {scope: this,fn: this.addRecord,buffer: 200}
                }
            }]
    }); // eo apply       


    // call parent
          Grid.Selection.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
// }}}
// {{{
,onRender: function() {
    // call parent
    Grid.Selection.superclass.onRender.apply(this, arguments);        
} // eo function onRender
// }}}
// {{{
,addRecord: function() {
    record = this.store.recordType;
    rec = new record({
        ...
    });
    this.stopEditing();
    this.store.insert(0, rec);
    **this.getView().refresh(); // GETTING ERROR ON THIS LINE**
    this.getSelectionModel().selectRow(0);
    this.startEditing(0, 0);
} // eo function addRecord    

,reset: function() {
    this.store.removeAll();
    this.addRecord();
}
}); // eo extend


// register xtype
Ext.reg('selectionGrid', Grid.Selection);

Я добавляю эту сетку в форму. Когда я отображаю форму, я сбрасываю сетку, которая удаляет все записи из хранилища и добавляет одну новую запись. Но когда this.getView (). Refresh (); называется я получаю

this.grid не определено this.grid.stopEditing (истина); ext-all-debug.js (строка 47393)

также вызывается плагин для удаления предметов [http://code.google.com/p/extensive/s...eleter.js?r=13] grid.getView (). refresh (), но это работает.

Буду очень признателен, если кто-нибудь сможет мне помочь.

1 Ответ

3 голосов
/ 31 октября 2011

Проблема заключалась в том, что сетка не была полностью отрисована до того, как я вызвал getView (). Refresh ().

Решением было вызвать вышеуказанный метод после визуализации сетки.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...