To fetch records between specific range from database you need to use the following function from SampleSQLProxy.
This function will give customized store, all the records between range limitMin and limitMax will be fetched.. in case of success functionSuccessObj will be called
In case of failure functionErrorObj.Here tableName is the name of table
getCustomizedStore:function(storeName,functionSuccessObj,functionErrorObj,tableName,limitMin,limitMax){
// create the store object to be returned with filled data
var storeObj;
//Obtain database Object
var dbObj=FOSSencha.util.AtosSQLProxy.getdatabaseObj();
//create callback function to proceed
dbObj.transaction(getCustomizedStoreQueryDB, getCustomizedStoreErrorCB);
// Query the database
function getCustomizedStoreQueryDB(tx) {
tx.executeSql('SELECT * FROM '+tableName +' limit '+limitMin+','+limitMax, [], getCustomizedStoreQuerySuccess, getCustomizedStoreErrorCB);
}
// Query the success callback
function getCustomizedStoreQuerySuccess(tx, results) {
//create the store object, fill the store object with model object and return to the function
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 getCustomizedStoreErrorCB(err) {
functionErrorObj(err);
}
}
—————————————————-
Posted By :
Manish Kumar Choithani
Senior /Lead Architect
Reference Email Ids:
[email protected]
[email protected]
[email protected]
[email protected]
This function will give customized store, all the records between range limitMin and limitMax will be fetched.. in case of success functionSuccessObj will be called
In case of failure functionErrorObj.Here tableName is the name of table
getCustomizedStore:function(storeName,functionSuccessObj,functionErrorObj,tableName,limitMin,limitMax){
// create the store object to be returned with filled data
var storeObj;
//Obtain database Object
var dbObj=FOSSencha.util.AtosSQLProxy.getdatabaseObj();
//create callback function to proceed
dbObj.transaction(getCustomizedStoreQueryDB, getCustomizedStoreErrorCB);
// Query the database
function getCustomizedStoreQueryDB(tx) {
tx.executeSql('SELECT * FROM '+tableName +' limit '+limitMin+','+limitMax, [], getCustomizedStoreQuerySuccess, getCustomizedStoreErrorCB);
}
// Query the success callback
function getCustomizedStoreQuerySuccess(tx, results) {
//create the store object, fill the store object with model object and return to the function
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 getCustomizedStoreErrorCB(err) {
functionErrorObj(err);
}
}
—————————————————-
Posted By :
Manish Kumar Choithani
Senior /Lead Architect
Reference Email Ids:
[email protected]
[email protected]
[email protected]
[email protected]