I add new rows(records) in to the grid when load
store event as bellow
var dt = new Date();
var rec = new store.recordType({ }, "new" + dt.format('U'));
rec.set('ID', '1');
store.insert(store.getCount(), rec);
store.insert(store.getCount()+1, rec);
grid.getView().refresh();
but i can't add 2 empty last rows in to the grid. how can i add 2 empty row in to the grid.
Note: without this line only add one row in to the grid store.insert(store.getCount()+1, rec);
but when i add store.insert(store.getCount()+1, rec);
in to my code that gave to me error.
First some comment concerning your code snipped:
You are creating a new record with the ID value "new" + dt.format('U')
and in the next line you are setting this ID to 1? You should create the record with the appropriate (and unique) ID. Otherwise you may override a existing record.
Now your problem:
You are adding a record with the same ID twice. So for the store there is only one record. Either don't assign a ID value at all and let ExtJS take care of it or ensure that each instance get it's own unique ID. And create a new instance each time!
You need to do something like this:
var rec1 = new store.recordType({}, 1); // remove the 1 with your own unique ID value
var rec2 = new store.recordType({}, 2); // remove the 2 with your own unique ID value
store.insert(store.getCount()-1, [rec1,rec2]);