You can use the following function to populate specific columns in store:
getStoreBasedOnQuerySpecificColumn : This function will give store with data obtained from DataQuery, note only columns specified in the modelColumnArray will be populated in store in case of success functionSuccessObj will be called. In case of failure functionErrorObj.
Note the order of elements in dataQuery and modelColumnArray should match to get proper results
getStoreBasedOnQuerySpecificColumn:function(storeName,functionSuccessObj,functionErrorObj,dataQuery,modelColumnArray){
// create the store object to be returned with filled data
var storeObj;
var dbObj=FOSSencha.util.SampleSQLProxy.getdatabaseObj();
//create callback function to proceed
dbObj.transaction(getStoreBasedOnQuerySpecificColumnQueryDB, getStoreBasedOnQuerySpecificColumnErrorCB);
// Query the database
function getStoreBasedOnQuerySpecificColumnQueryDB(tx) {
tx.executeSql(dataQuery, [], getStoreBasedOnQuerySpecificColumnQuerySuccess, getStoreBasedOnQuerySpecificColumnErrorCB);
}
// Query the success callback
function getStoreBasedOnQuerySpecificColumnQuerySuccess(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 = modelColumnArray;
for(var j=0, l=(items.length); 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);
}
function getStoreBasedOnQuerySpecificColumnErrorCB(err) {
functionErrorObj(err);
}
}
—————————————————-
Posted By :
Manish Kumar Choithani
Senior /Lead Architect
Reference Email Ids:
[email protected]
[email protected]
[email protected]
[email protected]
getStoreBasedOnQuerySpecificColumn : This function will give store with data obtained from DataQuery, note only columns specified in the modelColumnArray will be populated in store in case of success functionSuccessObj will be called. In case of failure functionErrorObj.
Note the order of elements in dataQuery and modelColumnArray should match to get proper results
getStoreBasedOnQuerySpecificColumn:function(storeName,functionSuccessObj,functionErrorObj,dataQuery,modelColumnArray){
// create the store object to be returned with filled data
var storeObj;
var dbObj=FOSSencha.util.SampleSQLProxy.getdatabaseObj();
//create callback function to proceed
dbObj.transaction(getStoreBasedOnQuerySpecificColumnQueryDB, getStoreBasedOnQuerySpecificColumnErrorCB);
// Query the database
function getStoreBasedOnQuerySpecificColumnQueryDB(tx) {
tx.executeSql(dataQuery, [], getStoreBasedOnQuerySpecificColumnQuerySuccess, getStoreBasedOnQuerySpecificColumnErrorCB);
}
// Query the success callback
function getStoreBasedOnQuerySpecificColumnQuerySuccess(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 = modelColumnArray;
for(var j=0, l=(items.length); 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);
}
function getStoreBasedOnQuerySpecificColumnErrorCB(err) {
functionErrorObj(err);
}
}
—————————————————-
Posted By :
Manish Kumar Choithani
Senior /Lead Architect
Reference Email Ids:
[email protected]
[email protected]
[email protected]
[email protected]