Note-This will populate complete store - all the records of the table will be filled. If store had some previous data, it will be deleted...
getDataFilledStore:function(storeName,functionSuccessObj,functionErrorObj,tableName){
// create the store object to be returned with filled data
var storeObj;
//Obtain database Object
//var dbObj=FOSSencha.app.getController(FOSSencha.util.Config.getAtosSQLProxy()).getda//tabaseObj();
var dbObj=FOSSencha.util.AtosSQLProxy.getdatabaseObj();
//create callback function to proceed
dbObj.transaction(getDataFilledStoreQueryDB, getDataFilledStoreErrorCB);
// Query the database
function getDataFilledStoreQueryDB(tx) {
tx.executeSql('SELECT * FROM '+tableName, [], getDataFilledStoreQuerySuccess, getDataFilledStoreErrorCB);
}
function getDataFilledStoreQuerySuccess(tx, results) {
storeObj=Ext.getStore(storeName);
var len = results.rows.length;
for (var i=0; i<len; i++) {
var modelname=Ext.getStore(storeName).config.model;
var customerRecord = Ext.create(modelname, {})
var items = customerRecord.getFields().keys;
for(var j=0, l=(items.length-1); j < l; j++){
var fieldName=items[j];
customerRecord.set(fieldName,results.rows.item(i)[fieldName]);
}
storeObj.add(customerRecord);
}
//return the callback function with storeObj
functionSuccessObj(storeObj);
}
// Transaction error callback
function getDataFilledStoreErrorCB(err) {
functionErrorObj(err);
}
},
You can call this function from your code as follows
<appname>.util.SampleSQLProxy.<functionname>(parameters);
—————————————————-
Posted By :
Manish Kumar Choithani
Senior /Lead Architect
Reference Email Ids:
[email protected]
[email protected]
[email protected]
[email protected]