extjs - Adding rows to grid -


i trying add rows grid.

i saw example in docs:

onaddrouteclick: function(){     // create model instance     var rec = new kitchensink.model.grid.plant({         buying_vendor_id: 12,         country_code: '1',         route: 0     });      this.getstore().insert(0, rec);     this.cellediting.starteditbyposition({         row: 0,          column: 0     }); } 

but cant seem make work in code.

this grid:

onbtnroutessearchclick: function(button, e, options){     var me = this;     var v_url = 'getroutes.jsp?' + ext.urlencode({'route_id': routeid, 'route_country_code' : routecountrycode , 'route_vendor_id' : routevendorid});      var newtab = ext.create('ext.panel.panel', {         id: 'routes_pannel',         title: 'routes',         autoscroll: true,         layout: {             type: 'fit'         },         closable: true,         dockeditems: [             {                 xtype: 'toolbar',                 dock: 'top',                 items: [                     {                         xtype: 'button',                         id: 'buttonresetbid',                         icon: 'images/plus.png',                         text: 'add row',                         listeners: {                             click: {                                 fn: me.onaddrouteclick,                                 scope: me                             }                         }                     }                 ]             }         ],         items:  [{             id: 'routes_grid',             xtype: 'gridpanel',             autoshow: false,             autoscroll: true,             store:  ext.create('ext.data.store', {                 fields:[                 {name: 'buying_vendor_id', type: 'int', sorttype: 'asint'},                 {name: 'country_code', type: 'int', sorttype: 'asint'},                 {name: 'route', type: 'int', sorttype: 'asint'}                 ],                 proxy: {                     type: 'ajax',                     timeout: 120000,                     url: v_url,                     reader: {                         type: 'json',                         root: 'data',                         successproperty: 'success'                     }                 },                 autoload: true             }),             columns: [                 {                     xtype: 'gridcolumn',                     dataindex: 'buying_vendor_id',                     width: 100,                     text: 'buying vendor'                 },                 {                     xtype: 'gridcolumn',                     dataindex: 'country_code',                     width: 100,                     text: 'country code'                 },                 {                     xtype: 'gridcolumn',                     dataindex: 'route',                     width: 80,                     text: 'route'                 }             ],         }]     });      var panel = ext.getcmp("maintabpanelid");     panel.add(newtab).show(); 

}

any ideas?

1.create model

ext.define('product', {     extend: 'ext.data.model',      fields: [         {name: 'productid'},         {name: 'productname'},          {name: 'unitprice'},         {name: 'unitsinstock'}     ] }); 

2.create rowediting

var reditor = ext.create('ext.grid.plugin.rowediting', {     clickstoedit: 2,      listeners: {edit: function (editor, e) { }); }  }); 

3.get store , create 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') }); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -