PDA

View Full Version : add new row in data grid panel



nimaous
1 Jun 2012, 1:24 PM
Hi
is there any method for Ext.grid.Panel to add a new row to our data grid

scottmartin
1 Jun 2012, 1:46 PM
You can use store.insert(), or store.add()

Regards,
Scott.

nimaous
1 Jun 2012, 1:59 PM
tnx for reply

this is my code in controller
but when I add store.insert or store.add I got error which is add or insert method are undefined

onButtonClick: function(button , e , options){
var grid=Ext.ComponentQuery.query('#WaitersDataGrid');
grid.store.add();

}

scottmartin
1 Jun 2012, 2:05 PM
Do you objects resolve as expected?
console.log(grid); // or grid.store?

If you are using MVC, you should be able to use something like:



stores: ['Waiters'];
..
var store = this.getWaitersStore();



Scott.

nimaous
1 Jun 2012, 2:17 PM
yes I use
stores : 'WaitersListStore' in my controller
and update my onButtonClick function like below but I got same error

var store = this.getWaitersListStoreStore();
var grid=Ext.ComponentQuery.query('#WaitersDataGrid');
grid.store.insert();

scottmartin
1 Jun 2012, 2:27 PM
Please see how you variables resolve in the console as mentioned in my last post.

Scott.

nimaous
1 Jun 2012, 10:10 PM
app/controller/WaitersConstroller.js?_dc=1338617262502:33 (http://localhost/myproject/Waiters/app/controller/WaitersConstroller.js?_dc=1338617262502)here is console.log(grid)

[
constructor


body: constructor
bodyCls: " x-grid-body"
collapseDirection: "top"
columns: Array[11]
componentCls: "x-panel"
componentLayout: constructor
componentLayoutCounter: 2
container: constructor
dockedItems: constructor
editingPlugin: constructor
el: constructor
events: Object
features: Array[0]
frame: undefined
hasListeners: HasListeners
hasView: true
header: constructor
headerCt: constructor
height: 328
hiddenOnCollapse: constructor
id: "WaitersDataGrid"
initialConfig: Object
isEditable: true
items: constructor
lastBox: Object
layout: constructor
layoutCounter: 2
loader: null
managedListeners: Array[4]
mons: Array[0]
ownerCt: constructor
ownerLayout: constructor
plugins: Array[1]
protoEl: null
renderData: Object
renderSelectors: Object
rendered: true
scrollTask: Ext.util.DelayedTask
selModel: constructor
stateEvents: Array[0]
stateId: undefined
store: constructor
title: "Waiters"
tools: Array[0]
ui: "default"
view: constructor
viewConfig: Object
xtype: "gridpanel"
__proto__: TemplateClass

scottmartin
2 Jun 2012, 5:48 AM
And you store constructor? as that is the one having problems with the add method.

Scott.