View Full Version : Grid: Dinamycally adding and removing rows

1 Mar 2007, 12:36 PM
What would be the _right_ way of dinamycally adding and removing rows in the new (1.0) grid?

Thanks a lot for this wonderful piece of engineering.

1 Mar 2007, 2:50 PM
add, remove and insert methods.

6 Mar 2007, 6:26 AM
What parameters should these functions receive?

The add function in Store.js is this one:

add : function(records){
records = [].concat(records);
for(var i = 0, len = records.length; i < len; i++){
var index = this.data.length;
this.fireEvent("add", this, records, index);

And everything I send to it (arrays, objects, etc) fails in the join inside the loop.

I know the library is in Alpha and docs are incomplete, but I'm trying to do my best looking at the source code and I just can't figure it out.


6 Mar 2007, 7:02 AM
You'll be adding a Record.

The constructor for this Record is generated by Ext.data.Record.create(), and passed to the Reader constructor as the 2nd param.

Call that constrctor with new(), and pass an array of data, and an id. Try adding the result of that.

6 Mar 2007, 7:41 AM
Assuming you have a datastore named ds and a selectionmodel named sm:

Adding a record:
var recordData = {someData:'bla',someMoreData:'blalbla'};
ds.add(new ds.reader.recordType(recordData));

Deleting a record (curr selected row):
var deleteRow = sm.getSelected();

6 Mar 2007, 8:21 AM
Thanks a lot guys, it works now :) .

31 Mar 2007, 3:57 PM
ds.add appends the row at the end of the grid.

How can I put the new row at the top ?