view app/controller/Proben.js @ 18:9e1a40312bbe

Implemented a basic edit dialog. Data will be set to data/proben2.json url which is currently just a dummy file to make to request work. But currently no data is actually saved. The urls need to be replaced with the correct urls in the application backend.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Mon, 06 May 2013 16:41:39 +0200
parents a8efc4b96888
children f9b6de636ad0
line wrap: on
line source
Ext.define('Lada.controller.Proben', {
    extend: 'Ext.app.Controller',
    views: [
        'proben.List',
        'proben.Edit'
    ],
    stores: [
        'Proben'
    ],
    models: [
        'Probe'
    ],
    init: function() {
        console.log('Initialising the Proben controller');
        this.control({
            // CSS like selector to select element in the viewport. See
            // ComponentQuery documentation for more details.
            'probenlist': {
                // Map the "render" event to the given function.
                render: this.onPanelRendered,
                // Map Doubleclick on rows of the probenlist.
                itemdblclick: this.editProbe
            },
            'probenedit button[action=save]': {
                click: this.updateProbe
            }
        });
    },
    onPanelRendered: function() {
        console.log('The panel was rendered');
    },
    editProbe: function(grid, record) {
        console.log('Double click on ' + record.get('name'));
        // Create new window to edit the seletced record.
        var view = Ext.widget('probenedit');
        view.down('form').loadRecord(record);
    },
    updateProbe: function(button) {
        console.log('Click save');
        // We only have a reference to the button here but we really wnat to
        // get the form and the window. So first get the window and form and
        // the the record an values.
        var win = button.up('window');
        var form = win.down('form');
        var record = form.getRecord();
        var values = form.getValues();

        record.set(values);
        win.close();
        // synchronize the store after editing the record
        // NOTE: The function 'getProbenStore' will be generated
        // dynamically based on the Name of the configured Store!!!
        this.getProbenStore().sync();
    }
});

http://lada.wald.intevation.org