Adding an empty row to a grid

前端 未结 2 2026
遇见更好的自我
遇见更好的自我 2021-01-16 03:52

I am trying to add rows to my grid.

I saw an example in the docs:

onAddRouteClick: function(){
// Create a model instance
var rec = new KitchenSink.m         


        
2条回答
  •  深忆病人
    2021-01-16 03:59

    1.Create your model

     Ext.define('Product', {
            extend: 'Ext.data.Model',
            fields:
                [
                    { name: 'ProductID' },
                    { name: 'ProductName' },
                    { name: 'UnitPrice' },
                    { name: 'UnitsInStock' }
                ]
        });
    

    2.create your rowEditing

     var rEditor = Ext.create('Ext.grid.plugin.RowEditing', {
                clicksToEdit: 2,
                listeners:
                    {
                        edit: function (editor, e) { });
                    }
            });
    

    3.get Store and create your grid

     var grid = Ext.create('Ext.grid.Panel', {
                store: store,
                plugins: [rEditor],
                title: 'Products',
                columns:
                    [
                    ],
                dockedItems:
                [
                    {
                        xtype: 'toolbar',
                        dock: 'top',
                        items:
                            [
                                {
                                    xtype: 'button',
                                    text: 'Yeni',
                                    listeners:
                                        {
                                            click:
                                                {
                                                    fn: function () {
    
                                              store.insert(0, new Product());
                                                rEditor.startEdit(0, 0);
                                            }
                                        }
                                }
                        }
                    ]
            }
        ],
        width: 450,
        renderTo: Ext.getElementById('hede')
    });
    

提交回复
热议问题