PDA

View Full Version : How To Add ,Delete Rows in grid



reddy479
30 Oct 2012, 7:12 AM
In My application,Iam Having The AddRow,Delete Row Buttons In Grid How To Add&Delete That Rows, In Grid,

Iam Using this Code,
var addrow=Ext.create('lib.Commons.Button', {
text: 'Add Row',
cls:'buttonPaddings',
listeners : {
click : function(){
var createnewcontactGridPanel = Ext.getCmp('creategrid');
alert(creategrid);






}
}




});
var deleterow=Ext.create('lib.Commons.Button', {
text: 'Delete Row',
cls:'buttonPaddings',

});
please Give Me The Replay,

Farish
30 Oct 2012, 7:17 AM
you have to add/delete records in the store bound to your grid. you cannot perform these actions on the grid. The grid is just the display element; the data is contained in the store.


store.add(record); // adds a record to your store
store.remove(record); // removes a record from your store

you can also pass an array instead of a single record to these functions and add or remove multiple records at once.

To get the selected records for deleting, you can use:


var srecords = grid.getSelectionModel().getSelection(); // returns an array of selected record(s)