[SOLVED]General question - SQLiteStore Loading + Combo
Hello All,
I've noticed a lot of threads circling around some of the same issues. I was wondering if it would not be a bad idea to put together a small thread like Makana did with the ext-air.js updated build.
From what I see, there are several threads and issues surrounding Comboboxes and SQLite stores. There are also some good threads on how to make this easier but thre are no definiteve guides. Grids are fantastic, but if you are using an editable grid, you will run into requiring comboboxes nevertheless.
Just was wondering if a how-to SQLite store+combo+filters+clauses would not be bad to have?
I myself have been beating my head at a wall week trying to understand how to filter/use clauses in the SQLite store . I'm sure I will not be the first and last to come across this.
Just a thought
Jack
viewName parameter inclusion not working
Hello Makana,
I tested the viewName parameter in my combo store and I'm getting the following error:
Code:
Error #1056: Cannot create property stackTrace on flash.errors.SQLError.
I tried to implement your code directly into ext-air.js but somehow may have done something wrong. Definitely should include this parameter extension into the ext-air.js
This is how to implemented your extension code:
Code:
****around line 1653:
getTable : function(name, keyName){
return new Ext.sql.Table(this, name, keyName);
},
//SQLite Modification - Extention
//Makana viewName parameter
getView: function(name){
return new Ext.sql.View(this, name);
}, //eo mod
****around line 2000
.......onRemove : function(ds, record, index){
var kn = this.table.keyName;
this.table.removeBy(kn + ' = ?', [record.data[kn]]);
}
});
/SQLite Modification - Extention
//Makana viewName parameter
Ext.sql.View = Ext.extend(Ext.sql.Table, {
constructor: function(conn, name) {
this.conn = conn;
this.name = name;
},
update: Ext.emptyFn,
updateBy: Ext.emptyFn,
insert: Ext.emptyFn,
lookup: Ext.emptyFn,
exists: Ext.emptyFn,
save: Ext.emptyFn,
remove: Ext.emptyFn,
removyBy: Ext.emptyFn
});
//eo mod
Ext.sql.AirConnection = Ext.extend(Ext.sql.Connection, {
// abstract methods
open : function(db){
this.conn = new air.SQLConnection();
var file = air.File.applicationDirectory.resolvePath(db);
this.conn.open(file);
this.openState = true; ......
****Overwrite the store definition
****Around line 1700
Ext.sql.SQLiteStore = Ext.extend(Ext.data.Store, {
constructor: function(config) {
config = config || {};
config.reader = new Ext.data.JsonReader({
idProperty: config.key,
totalProperty: config.totalProperty,
root: config.root,
fields: config.fields
});
var conn;
if (!config.conn || config.dbFile) {
conn = Ext.sql.Connection.getInstance();
conn.open(config.dbFile);
} else conn = config.conn;
/*
if (config.createTable === true) conn.createTable({
name: config.tableName,
key: config.key,
fields: config.reader.recordType.prototype.fields
});*/
//Makana's extension for viewName
if (!config.viewName) {
conn.createTable({
name: config.tableName,
key: config.key,
fields: config.reader.recordType.prototype.fields
});
var table = conn.getTable(config.tableName, config.key);
} else var table = conn.getView(config.viewName);
Ext.sql.SQLiteStore.superclass.constructor.call(this, config);
this.proxy = new Ext.sql.Proxy (conn, table, this, config.api);
}
});
Combo store issue - using Views
Hello Makana,
So I've undone all the changes I made and have reverted back to the original modified ext-air-debug.
But I can seem to get away from this error:
Code:
Error #1056: Cannot create property stackTrace on flash.errors.SQLError.
Here is how I've defined my view:
Code:
CREATE VIEW "VW_COUNTRY_ADMINS" AS SELECT ADMINISTRATOR_ID as id, ADMINISTRATOR_NAME as text FROM ORI_ADMINISTRATORS WHERE ADMINISTRATOR_TYPE = 'COUNTRY' ORDER BY 2
Here is my custom XTYPE combo:
Code:
iApplication.module.comboCountryAdmins = Ext.extend(Ext.form.ComboBox,
{
initComponent: function()
{
Ext.apply(this, {
store: new Ext.sql.SQLiteStore({
conn: iApplication.module.DB
,api:{create:false,update:false,destroy:false}
,tableName: 'VW_COUNTRY_ADMINS'
//,key: 'ADMINSTRATOR_ID'
,key: 'id'
,fields: [
{name: 'id', type: 'int'}
,{name: 'text', type: 'string'}
]
}),
valueField: 'id'
,displayField: 'text'
,triggerAction: 'all'
//,typeAhead: false
,emptyText:'Select Employee...'
,width: 160
,fieldLabel: 'Employee'
,lazyRender: true
,tpl: Templates.comboTpl
})
iApplication.module.comboCountryAdmins.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg('combo-country-admins', iApplication.module.comboCountryAdmins);
And finally my template:
Code:
Templates = {
comboTpl: new Ext.XTemplate(
'<tpl for="."><div class="x-combo-list-item">{text}</div></tpl>'
)};
I've tried many combinations, but I'm not sure if the problem is with the store, or the template?
Any thoughts
Thanks Jack