/*
 * File: app/view/KittensListItem.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.view.KittensListItem', {
    extend: 'Ext.dataview.component.DataItem',
    alias: 'widget.kittenslistitem',

    config: {
        padding: 10,
        style: 'background-color: yellow;',
        layout: {
            align: 'center',
            type: 'hbox'
        },
        items: [
            {
                xtype: 'sliderfield',
                flex: 1,
                style: 'background-color: red;',
                name: 'Valore',
                maxValue: 30
            },
            {
                xtype: 'formpanel',
                flex: 1,
                height: 70,
                itemId: 'form',
                style: 'background-color: red;',
                layout: {
                    type: 'fit'
                },
                items: [
                    {
                        xtype: 'sliderfield',
                        itemId: 'Valore',
                        style: 'background-color: green;',
                        name: 'Valore',
                        maxValue: 30
                    }
                ]
            }
        ]
    },

    updateRecord: function(record) {
        // Provide an implementation to update this container's child items
        me = this;
        this.down("#form").setRecord(record);
        //console.log(this.down("#form").getRecord());

        // Imposta il valore per ogni oggetto con il corrisponedente name, la
        // proprietà che viene usata dal form panel per eseguire l'associazione
        for(var fieldName in record.raw){
            control = me.down('[name=' + fieldName + ']');
            //control = me.down('#' + fieldName); //lo recuper impostando il nome nella proprieta itemId invece di usare qualla name.

            if (control) 
            control.setValue(record.get(fieldName));
        }

        //this.down("#" + fieldName).setValue(record.get(fieldName));
        //console.log(this.down("#form").getRecord());
    }

});