Spirit
13 Sep 2007, 7:20 AM
I have a grid where I insert a row each time a button is pressed.
My data for the new row depends on the last row in the grid.
To get the lastrow in datastore i use the function grid.datastore.getTotalCount but these function wont give back the right value. The datasource of the grid is initialized with 1 row. (Datastore with json reader)
After i insert a new record, the function grid.datastore.getTotalCount still returns 1, but in
grid.dataSource.data.length the right value is available.
The new row will also be shown in the grid. But the getTotalCount of datastore wont update ?!?!
In grid.datasource.reader.jsondata the totalcount value doesnt change. This may be right, because i dont know if i add the new row the right way, maybe there is a another way so that the row is recognized by the reader and the right value will be returnd ?
Here the code 4 the store:
var storeSeasonsGrid = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'query2.php'
}),
reader: new Ext.data.JsonReader(),
remoteSort: true
});
and the part of code (shortend) where i add the new row (in a grid toolbar button handler)
seasongrid.stopEditing();
var config = [];
var tmprecord=seasongrid.dataSource.getAt(seasongrid.dataSource.getTotalCount()-1);
config[seasongrid.dataSource.fields.keys[2]] = tmprecord.data['season'];
var newRow = new seasongrid.dataSource.reader.recordType(config);
seasongrid.dataSource.add(newRow);
alert(seasongrid.dataSource.getTotalCount()); // <- gives wrong value, alwas 1 indepent of how much rows i add
alert(seasongrid.dataSource.data.length); <- gives the expected value 1,2,3,4,...
Can someone explain me this behavior ?
I can get my function to work, but i dont like bypassing provided functions.
Seems i have done someting wrong :-?
My data for the new row depends on the last row in the grid.
To get the lastrow in datastore i use the function grid.datastore.getTotalCount but these function wont give back the right value. The datasource of the grid is initialized with 1 row. (Datastore with json reader)
After i insert a new record, the function grid.datastore.getTotalCount still returns 1, but in
grid.dataSource.data.length the right value is available.
The new row will also be shown in the grid. But the getTotalCount of datastore wont update ?!?!
In grid.datasource.reader.jsondata the totalcount value doesnt change. This may be right, because i dont know if i add the new row the right way, maybe there is a another way so that the row is recognized by the reader and the right value will be returnd ?
Here the code 4 the store:
var storeSeasonsGrid = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'query2.php'
}),
reader: new Ext.data.JsonReader(),
remoteSort: true
});
and the part of code (shortend) where i add the new row (in a grid toolbar button handler)
seasongrid.stopEditing();
var config = [];
var tmprecord=seasongrid.dataSource.getAt(seasongrid.dataSource.getTotalCount()-1);
config[seasongrid.dataSource.fields.keys[2]] = tmprecord.data['season'];
var newRow = new seasongrid.dataSource.reader.recordType(config);
seasongrid.dataSource.add(newRow);
alert(seasongrid.dataSource.getTotalCount()); // <- gives wrong value, alwas 1 indepent of how much rows i add
alert(seasongrid.dataSource.data.length); <- gives the expected value 1,2,3,4,...
Can someone explain me this behavior ?
I can get my function to work, but i dont like bypassing provided functions.
Seems i have done someting wrong :-?