extjs - Adding an empty row to a 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 }); 

}

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(); 

so trying add record store right? ok, lets @ store api http://docs.sencha.com/extjs/4.1.3/#!/api/ext.data.store-method-add

sample usage:

   mystore.add({some: 'data'}, {some: 'other data'}); 

the best practice create model class . read component guides on grid , data package .


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 -