source: trunk/web/addons/job_monarch/lib/extjs/air/src/sql/SQLiteStore.js @ 619

Last change on this file since 619 was 619, checked in by ramonb, 15 years ago

lib/:

  • added new AJAX dependancies: ExtJS, pChart, Lightbox2
File size: 1.5 KB
Line 
1/*
2 * Ext JS Library 0.30
3 * Copyright(c) 2006-2009, Ext JS, LLC.
4 * licensing@extjs.com
5 *
6 * http://extjs.com/license
7 */
8
9/**
10 * @class Ext.sql.SQLiteStore
11 * @extends Ext.data.Store
12 * Convenience class which assists in setting up SQLiteStore's.
13 * This class will create the necessary table if it does not exist.
14 * This class requires that all fields stored in the database will also be kept
15 * in the Ext.data.Store.
16 */
17Ext.sql.SQLiteStore = Ext.extend(Ext.data.Store, {
18    /**
19     * @cfg {String} key This is the primary key for the table and the id for the Ext.data.Record.
20     */
21    /**
22     * @cfg {Array} fields Array of fields to be used. Both name and type must be specified for every field.
23     */
24    /**
25     * @cfg {String} dbFile Filename to create/open
26     */
27    /**
28     * @cfg {String} tableName  Name of the database table
29     */
30    constructor: function(config) {
31        config = config || {};
32        config.reader = new Ext.data.JsonReader({
33            id: config.key,
34            fields: config.fields
35        });
36        var conn = Ext.sql.Connection.getInstance();
37       
38        conn.open(config.dbFile);
39        // Create the database table if it does
40        // not exist
41        conn.createTable({
42            name: config.tableName,
43            key: config.key,
44            fields: config.reader.recordType.prototype.fields
45        });               
46        Ext.sql.SQLiteStore.superclass.constructor.call(this, config);
47        this.proxy = new Ext.sql.Proxy(conn, config.tableName, config.key, this, false);       
48    }
49});
Note: See TracBrowser for help on using the repository browser.