I had a hard finding a simple code sample demonstrating ExtJS binding to an AIR SQLite database. I'm posting here for anyone looking for a few lines of code to get them started.
With some help from the sample app, here's the shortest code snippet I could cook up:
Code:
myConn = Ext.sql.Connection.getInstance();
myConn.open('clippy2.db.sqlite');
ClipStore = Ext.extend(Ext.data.Store, {
clipsRecord: Ext.data.Record.create([
{name: 'id', type:'string'}, // this is your db schema
{name: 'title', type:'string'},
{name: 'clip', type:'string'}
]),
constructor: function(){
ClipStore.superclass.constructor.call(this, {
sortInfo:{field: 'title', direction: "ASC"},
reader: new Ext.data.JsonReader({
id: 'id',
fields: this.clipsRecord
})
});
this.conn = myConn;
this.proxy = new Ext.sql.Proxy(myConn, 'clips', 'id', this);
}
});
mx = new ClipStore;
mx.load();
air.Introspector.Console.log(ClipStore); // evidence the store has your data!