ExtJs Store no record found, but saved one recently
Im working on a project with Sencha Touch and the sqLite proxy you can
find here
I have this WorkShift model which is used by WorkShifts store.
Model:
Ext.define('KCS.model.WorkShift', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', type: 'int' },
{ name: 'WorkShiftID', type: 'int' },
{ name: 'StartDate', type: 'date' },
{ name: 'ClosureDate', type: 'date' },
],
proxy: {
type: 'sqlitestorage',
dbConfig: {
tablename: 'tbl_WorkShift',
dbConn: KCS.util.InitSQLite.getConnection()
}
}
}
});
And the store:
Ext.define('KCS.store.WorkShifts', {
extend: 'Ext.data.Store',
requires: ['KCS.model.WorkShift'],
config: {
model: 'KCS.model.WorkShift',
autoLoad: true,
storeId: 'WorkShifts',
pageSize: 1000
}
});
Now, in my Controller, i want to see if there is an opened WorkShift (if
the app crashed or was closed without closing the last Workshift.) So i
use the launch callback like this:
launch : function(){
var workShifts = Ext.getStore('WorkShifts');
workShifts.clearFilter(true);
var openedWS = workShifts.findBy( function( record ){
return (record.get("StartDate") != null) &&
(record.get("ClosureDate") == null);
});
if( openedWS != -1 ){
// do stuff when an opened WS is found
}
else{
// do normal stuff
}
},
I did a bunch of tests, First, there is a bunch of valid entries in my
sqLite proxy, and i can create WS from the store and model. There is also
an entry that meets the findBy function filter. I've tried
workShifts.getCount() and even workShifts.getAllCount() but both functions
return 0. What the hell is happening?
No comments:
Post a Comment