/*
 * File: app/controller/Main.js
 *
 * This file was generated by Sencha Architect version 2.2.2.
 * http://www.sencha.com/products/architect/
 *
 * This file requires use of the Sencha Touch 2.2.x library, under independent license.
 * License of Sencha Architect does not include license for Sencha Touch 2.2.x. For more
 * details see http://www.sencha.com/license or contact license@sencha.com.
 *
 * This file will be auto-generated each and everytime you save your project.
 *
 * Do NOT hand edit this file.
 */

Ext.define('MyApp.controller.Main', {
    extend: 'Ext.app.Controller',

    config: {
        refs: {
            navBtn: 'button[name="nav_btn"]',
            lista: '#lista'
        },

        control: {
            "navBtn": {
                tap: 'toggleNav'
            }
        }
    },

    toggleNav: function(button, e, eOpts) {
        store =  Ext.data.StoreManager.lookup('teststore');
        store.sync();

        var b = Ext.create('MyApp.model.Test', {
            id : null,    
            Testo : "uno",
            Valore : 1
        });

        var c = Ext.create('MyApp.model.Test', {
            id : null,    
            Testo : "due",
            Valore : 2
        });

        /*var f = Ext.create('MyApp.view.MyFormPanel1');
        f.setRecord(c);
        if (!f.getParent()) {
        Ext.Viewport.add(f);
        }

        f.show();*/

        var aRecord = store.getById(1);
        aRecord.set('Valore', 5);
        return;
        //p = store.getProxy();
        //b.setProxy(p);

        //b.save();
        store.add(c);
        store.add(b);
        store.sync();

        /*b.save(function(a) { 
        Ext.Logger.log(a);
        });*/

        //this.getLista().refresh();
    }

});