1. #1
    Sencha Premium Member
    Join Date
    Sep 2009
    Posts
    42
    Vote Rating
    1
    op1op is on a distinguished road

      0  

    Default 4.2 cellmodel select error occurred

    4.2 cellmodel select error occurred


    grid cellmodel select row throw error like this Cannot read property 'view' of undefined ;
    in file src/selection/CellModel.js line 324
    Code:
    view = pos.view || me.primaryView;


    Use the example examples\kitchensink\app\view\grid\CellEditing.js

    add this.getSelectionModel().select(0);

    Code:
    Ext.define('KitchenSink.view.grid.CellEditing', {    extend: 'Ext.grid.Panel',
        
        requires: [
            'Ext.selection.CellModel',
            'Ext.grid.*',
            'Ext.data.*',
            'Ext.util.*',
            'Ext.form.*',
            'KitchenSink.model.grid.Plant'
        ],
        xtype: 'cell-editing',
        
        //<example>
        exampleTitle: 'Cell Editing Grid Example',
        exampleDescription: [
            '<p>This example shows how to enable users to edit the contents of a grid.</p>'
        ].join(''),
        themes: {
            classic: {
                width: 600,
                height: 300,
                indoorWidth: 55
            },
            neptune: {
                width: 680,
                height: 350,
                indoorWidth: 90
            }
        },
        //</example>
        
        title: 'Edit Plants',
        frame: true,
        
        initComponent: function() {
            this.cellEditing = new Ext.grid.plugin.CellEditing({
                clicksToEdit: 1
            });
            
            Ext.apply(this, {
                width: this.themeInfo.width,
                height: this.themeInfo.height,
                plugins: [this.cellEditing],
                store: new Ext.data.Store({
                    // destroy the store if the grid is destroyed
                    autoDestroy: true,
                    model: KitchenSink.model.grid.Plant,
                    proxy: {
                        type: 'ajax',
                        // load remote data using HTTP
                        url: 'resources/data/grid/plants.xml',
                        // specify a XmlReader (coincides with the XML format of the returned data)
                        reader: {
                            type: 'xml',
                            // records will have a 'plant' tag
                            record: 'plant'
                        }
                    },
                    sorters: [{
                        property: 'common',
                        direction:'ASC'
                    }]
                }),
                columns: [{
                    header: 'Common Name',
                    dataIndex: 'common',
                    flex: 1,
                    editor: {
                        allowBlank: false
                    }
                }, {
                    header: 'Light',
                    dataIndex: 'light',
                    width: 130,
                    editor: new Ext.form.field.ComboBox({
                        typeAhead: true,
                        triggerAction: 'all',
                        selectOnTab: true,
                        store: [
                            ['Shade','Shade'],
                            ['Mostly Shady','Mostly Shady'],
                            ['Sun or Shade','Sun or Shade'],
                            ['Mostly Sunny','Mostly Sunny'],
                            ['Sunny','Sunny']
                        ],
                        lazyRender: true,
                        listClass: 'x-combo-list-small'
                    })
                }, {
                    header: 'Price',
                    dataIndex: 'price',
                    width: 70,
                    align: 'right',
                    renderer: 'usMoney',
                    editor: {
                        xtype: 'numberfield',
                        allowBlank: false,
                        minValue: 0,
                        maxValue: 100000
                    }
                }, {
                    header: 'Available',
                    dataIndex: 'availDate',
                    width: 95,
                    renderer: Ext.util.Format.dateRenderer('M d, Y'),
                    editor: {
                        xtype: 'datefield',
                        format: 'm/d/y',
                        minValue: '01/01/06',
                        disabledDays: [0, 6],
                        disabledDaysText: 'Plants are not available on the weekends'
                    }
                }, {
                    xtype: 'checkcolumn',
                    header: 'Indoor?',
                    dataIndex: 'indoor',
                    width: this.themeInfo.indoorWidth,
                    stopSelection: false
                }, {
                    xtype: 'actioncolumn',
                    width: 30,
                    sortable: false,
                    menuDisabled: true,
                    items: [{
                        icon: 'resources/images/icons/fam/delete.gif',
                        tooltip: 'Delete Plant',
                        scope: this,
                        handler: this.onRemoveClick
                    }]
                }],
                selModel: {
                    selType: 'cellmodel'
                },
                tbar: [{
                    text: 'Add Plant',
                    scope: this,
                    handler: this.onAddClick
                }]
            });
            
            this.callParent();
            
            this.on('afterlayout', this.loadStore, this, {
                delay: 1,
                single: true
            })
        },
        
        loadStore: function() {
            this.getStore().load({
                // store loading is asynchronous, use a load listener or callback to handle results
                callback: this.onStoreLoad
            });
        },
        
        onStoreLoad: function(){
            Ext.Msg.show({
                title: 'Store Load Callback',
                msg: 'store was loaded, data available for processing',
                icon: Ext.Msg.INFO,
                buttons: Ext.Msg.OK
            });
        },
        
        onAddClick: function(){
            // Create a model instance
            var rec = new KitchenSink.model.grid.Plant({
                common: 'New Plant 1',
                light: 'Mostly Shady',
                price: 0,
                availDate: Ext.Date.clearTime(new Date()),
                indoor: false
            });
            
            this.getStore().insert(0, rec);
    	this.getSelectionModel().select(0);//add this code
            this.cellEditing.startEditByPosition({
                row: 0, 
                column: 0
            });
        },
        
        onRemoveClick: function(grid, rowIndex){
            this.getStore().removeAt(rowIndex);
        }
    })

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,079
    Vote Rating
    186
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    Great question!
    Instead of using select() use setCurrentPosition(). The documentation isn't terribly explicit on how to select a cell using this method -vs- select()... yet.

    See the example below for usage:
    Code:
    Ext.create('Ext.data.Store', {
        storeId:'simpsonsStore',
        fields:['name', 'email', 'phone'],
        data:{'items':[
            { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224"  },
            { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234" },
            { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244"  },
            { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254"  }
        ]},
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
        }
    });
    
    
    Ext.create('Ext.grid.Panel', {
        title: 'Simpsons',
        store: Ext.data.StoreManager.lookup('simpsonsStore'),
        columns: [
            { text: 'Name',  dataIndex: 'name' },
            { text: 'Email', dataIndex: 'email', flex: 1 },
            { text: 'Phone', dataIndex: 'phone' }
        ],
        selType: 'cellmodel',
        tbar: [{
            text: 'Select'
            , handler: function (btn) {
                btn.up('gridpanel').getSelectionModel().setCurrentPosition({
                    row: 0
                    , column: 0
                });
            }
        }],
        height: 200,
        width: 400,
        renderTo: Ext.getBody()
    });

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2009
    Posts
    42
    Vote Rating
    1
    op1op is on a distinguished road

      0  

    Default


    Thank you!

    But is there any way to do this no matter the grid is cellmodel or rowmodel?

    It can use setCurrentPosition method ,but i may not want to determine the type of selectmodel.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,941
    Vote Rating
    635
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    This should be fixed up for 4.2.1. You can select by index/record even when using cell selection. It will default to the 1st cell if you specify an index or record.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha Premium Member
    Join Date
    Sep 2009
    Posts
    42
    Vote Rating
    1
    op1op is on a distinguished road

      0  

    Default


    Thank you!Great,That's what i want.

  6. #6
    Sencha User
    Join Date
    Aug 2013
    Posts
    7
    Vote Rating
    0
    krajaraman84 is on a distinguished road

      0  

    Default


    Cell Editing along with CellSelectionModel still giving error using 4.2.1.

    Previously i was using the same in other Ext Versions . It was working fine with out any issues.