Results 1 to 3 of 3

Thread: grid is not defined for grid.startEditing

  1. #1

    Default grid is not defined for grid.startEditing

    hello
    i have some problem creating a simple function for inserting new data

    this is a part of my code
    Code:
       xtype: 'button',
    cls : 'x-btn-icon',
    icon : 'images/icons/add.png',
    handler : function () {
    Ext.getCmp('gridmenu').getStore().insert(
    0,
    new article_model({
    title_article : 'new moie',
    texte_article : 'texte',
    })
     );
     grid.startEditing(0,0);
    }
    and the error is :
    Code:
    grid is not defined
    grid.startEditing(0,0);
    this is the entire code
    Code:
    /*
     * File: MyViewport.ui.js
     * Date: Tue Nov 09 2010 13:07:15 GMT+0100 (CET)
     * 
     * This file was generated by Ext Designer version xds-1.0.2.14.
     * http://www.extjs.com/products/designer/
     *
     * This file will be auto-generated each and everytime you export.
     *
     * Do NOT hand edit this file.
     */
    
    MyViewportUi = Ext.extend(Ext.Viewport, {
        layout: 'border',
        initComponent: function() {
            
        var article_model = Ext.data.Record.create ([
        'title_doc', 'texte_doc'
        ]);
            
            
            this.items = [
                {
                    xtype: 'panel',
                    title: 'mapforge v3',
                    region: 'north'
                },
                {
                    xtype: 'tabpanel',
                    activeTab: 0,
                    region: 'center',
                    width: 100,
                    items: [
                        {
                            xtype: 'panel',
                            title: 'Tab 1',
                            width: 1045,
                            layout: 'border',
                            items: [
                                {
                                    xtype: 'panel',
                                    layout: 'fit',
                                    region: 'west',
                                    width: 276,
                                    items: [
                                        {
                                            xtype: 'grid',
                                            title: 'Projets',
                                            store: 'StoreDoc',
                                            id: 'gridmenu',
                                              ref: '../../../grid',
                                            columns: [
                                                {
                                                    xtype: 'gridcolumn',
                                                    dataIndex: 'title_doc',
                                                    header: 'label',
                                                    sortable: true,
                                                    width: 300,
                                                    id: 'label'
                                                }
                                            ],
                                            tbar: {
                                                xtype: 'toolbar',
                                                items: [
                                                    {
                                                        xtype: 'buttongroup',
                                                        title: 'Buttons',
                                                        columns: 2,
                                                        items: [
                                                            {
                                                                xtype: 'button',
                                                                cls : 'x-btn-icon',
                                                                icon : 'images/icons/add.png',
                                                                handler : function () {
                                                                    Ext.getCmp('gridmenu').getStore().insert(
                                                                    0,
                                                                    new article_model({
                                                                        title_article : 'new moie',
                                                                        texte_article : 'texte',
                                                                    })
                                                                    );
                                                                    grid.startEditing(0,0);
                                                                    }
                                                            } ,
                                                            {
                                                                xtype: 'button',
                                                             
                                                                cls : 'x-btn-icon',
                                                                icon : 'images/icons/delete.png',
                                                                handler : function (){
                                                                    //Ext.Msg.alert('Boo', 'here i am');
                                                                    var sm =  Ext.getCmp('gridmenu').getSelectionModel();
                                                                    var sel = sm.getSelected();
                                                                    if(sm.hasSelection()){
                                                                        Ext.Msg.show ({
                                                                            title : 'Remove Movie',
                                                                            buttons : Ext.MessageBox.YESNOCANCEL,
                                                                            msg : 'Remove '+sel.data.title_doc+'?',
                                                                            fn:function(btn){
                                                                                if(btn == 'yes') {
                                                                                    Ext.getCmp('gridmenu').getStore().remove(sel);
                                                                                }
                                                                            }
                                                                        })
                                                                    }
                                                                    }
                                                            } 
                                                        ]
                                                    }
                                                ]
                                            }
                                        }
                                    ]
                                },
                                {
                                    xtype: 'panel',
                                    layout: 'fit',
                                    region: 'center',
                                    items: [
                                        {
                                            xtype: 'form',
                                            id: 'workspace',
                                            flex : 1,
                                            title: 'workspace',
                                            autoScroll: true,
                                           
                                            items: [
                                                {
                                                    xtype: 'fieldset',
                                                    items: [
                                                        {
                                                            xtype: 'textfield',
                                                            fieldLabel: 'titre',
                                                            anchor: '100%',
                                                            id: 'title_doc'
                                                        },
                                                        {
                                                            xtype: 'htmleditor',
                                                            anchor: '100%',
                                                            height: 150,
                                                            fieldLabel: 'texte',
                                                            id: 'texte_doc'
                                                        }
                                                    ]
                                                }
                                            ],
                                                                                    tbar: {
                                                xtype: 'toolbar',
                                                items: [
                                                    {
                                                        xtype: 'buttongroup',
                                                       
                                                        columns: 2,
                                                        items: [
                                                            {
                                                                xtype: 'button',
                                                                cls : 'x-btn-icon',
                                                                icon : 'images/icons/disk.png',
                                                                handler : function () {
                                                                    
                                                                    
                                                                    Ext.Msg.alert('Boo', 'here i am');
                                                                //Ext.getCmp('workspace').getForm().submit();
    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                    
                                                                     //grid.startEditing(0,0);
                                                                    }
                                                            } 
                                                        ]
                                                    }
                                                ]
                                            }
                                        }
                                    ]
                                }
                            ]
                        } ,
                        {
                            xtype: 'panel',
                            title: 'Tab 3',
                            tbar: {
                                xtype: 'mytoolbar'
                            }
                        }
                    ]
                }
            ];
            MyViewportUi.superclass.initComponent.call(this);
        }
    });
    thanks for your help !

  2. #2
    Sencha User
    Join Date
    Aug 2009
    Posts
    480

    Default

    How do you expect the grid variable to be defined?

    Try adding:

    Code:
     
    var grid = Ext.getCmp('gridmenu');
    Using Ext.getCmp internally is not a good practice tought, you should store a reference to the grid so that you can access it directly. The fact that the whole code is written in the viewport definition makes those things harder... I strongly recommend that you read Writing A Big Application In Ext.

  3. #3

    Default

    hello
    i have read the article "wrting a big application in ext" so i try to externalize some elements
    my first example : i have this in my main code
    Code:
     tbar: {
                                                xtype: 'toolbar',
                                                items: [
                                                    {
                                                        xtype: 'buttongroup',
                                                       
                                                        columns: 2,
                                                        items: [
                                                            {
                                                                xtype: 'button',
                                                                cls : 'x-btn-icon',
                                                                icon : 'images/icons/disk.png',
                                                                handler : function () {
                                                                Ext.Msg.alert('Boo', 'here i am');
                                                                //Ext.getCmp('workspace').getForm().submit();
                                                                //grid.startEditing(0,0);
                                                                    }
                                                            } 
                                                        ]
                                                    }
                                                ]
                                            }
    i change for this
    Code:
      tbar: {
                                                xtype: 'toolbar',
                                                items: [
                                                    {
                                                        xtype: 'save_form'
                                                    }
                                                ]
                                            }
    and after i create two new files
    this one
    Code:
    save_form = Ext.extend(saveui, {
        initComponent: function() {
          saveui.superclass.initComponent.call(this);
        }
    });
    Ext.reg('save_form', save_form);
    and this one
    Code:
    saveui = Ext.extend(Ext.Toolbar, {
        initComponent: function() {
            this.items = [
                {
                    xtype: 'buttongroup',
                    text: 'projet',
                    columns: 2,
                    items: [
                        {
                            xtype: 'button',
                            cls : 'x-btn-icon',
                            text : 'test save',
                            icon : 'images/icons/disk.png',
                            handler : function () {
                            Ext.Msg.alert('Boo', 'here i am');
                            }
                        }
                    ]
                }
            ];
           saveui.superclass.initComponent.call(this);
        }
    });
    and i add this new files in my html file
    Code:
        <script type="text/javascript" src="save.ui.js"></script>
        <script type="text/javascript" src="save.js"></script>
    but nothing happens in my interface
    what's wrong ?
    thks for your help

Similar Threads

  1. grid.startEditing(xmlStore.getCount()-1,0);
    By j11extjs in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 12 Oct 2010, 3:20 AM
  2. [SOLVED]Grid: No 'convert' defined
    By wora in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 23 Jul 2009, 2:05 AM
  3. startEditing the first cell when grid gotFocus
    By sh.claudio in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 3 Apr 2009, 5:34 AM
  4. Ext.grid.EditorGridPanel.startEditing delays 50ms, why?
    By OlleJonsson in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 24 Sep 2008, 9:01 PM
  5. grid.startediting and afteredit/validateedit events
    By jbowman in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 13 Apr 2007, 6:40 PM

Posting Permissions

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