1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    2
    Vote Rating
    0
    mdietger is on a distinguished road

      0  

    Default Unanswered: Data from controller to fieldset

    Unanswered: Data from controller to fieldset


    I've started today using Sencha Touch and ran into some trouble. I hope you guys can help me a bit.

    I've a list of customers and when i click on the disclosure button i want to display more detail of them in a from. Everything is working fine when displaying the detail is a simple Panel but when using a form in my view thing go wrong.

    My model
    Code:
    Ext.define('SSL.model.Klant', {
        extend: 'Ext.data.Model',
        
        config: {
            fields: ['seqklant', 'naam1', 'naam2', 'adres1', 'adres2', 'adres3', 'btw', 'tel', 'gsm', 'email']
        }
    })
    My store
    Code:
    Ext.define('SSL.store.Klanten', {
       extend: 'Ext.data.Store',
       
       config: {
           model: 'SSL.model.Klant',
           sorters: 'naam1',
           grouper: function(record){
             return record.get('naam1')[0];  
           },
           autoLoad: true,
           proxy:{
                type: 'jsonp',
                url: 'http://localhost/SSL/json.php',
                reader:{
                    type:'json',
                    rootProperty: 'responseData'
                }
            }
       }
    });
    My controller
    Code:
    Ext.define('SSL.controller.Klant', {
        extend: 'Ext.app.Controller',
        
        config: {
            refs: {
                klantView: 'KlantContainer'
            },
            control: {
                'KlantLijst': {
                    disclose: 'showDetail'
                }
            }
        },
        
        showDetail: function(list, record){
            this.getKlantView().push({
                xtype: 'KlantDetail',
                title: record.data['naam1'],
                data: record.data
            });
        }
    })
    And last but not least my View
    Code:
    Ext.define('SSL.view.KlantDetail', {
        extend: 'Ext.form.Panel',
        xtype: 'KlantDetail',
        
        config: {
            items: [{
                xtype: 'fieldset',
                items: [
                    {
                        xtype: 'textfield',
                        name : 'naam1',
                        label: 'Name',
                        tpl: '{naam1}',
                        readOnly: true
                    }
                ]
            }]
        } 
    })
    As you can see i try to obtain data from my store through my controller by assigning data to the record.data. When i used a simple Panel and a tpl i could obtain my data, but now when i'm using a from to display my data with a tpl it doesn't work anymore.

    Which is a correct way to obtain data in my form ?

    Thx in advance!

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    Answers
    41
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    try this:
    Code:
        showDetail: function(list, record){
            this.getKlantView().push({
                xtype: 'KlantDetail',
                title: record.data['naam1'],
                //data: record.data
                record: record
            });
        }

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    2
    Vote Rating
    0
    mdietger is on a distinguished road

      0  

    Default


    It works thx. Although the real question is how i could find the solution to this in the documentation myself?

    As someone new to sencha i went to the documentation of the textfield and looked for the tpl config

    http://docs.sencha.com/touch/2-1/#!/...d.Text-cfg-tpl

    which states the following
    Code:
    tpl : String/String[]/Ext.Template[]/Ext.XTemplate[]13
    A String, Ext.Template, Ext.XTemplate or an Array of strings to form an Ext.XTemplate. Used in conjunction with the data and tplWriteMode configurations.
    Note The data configuration must be set for any content to be shown in the component when using this configuration.
    
    
    Its says the data configuration must be set, yet in the solution you gave me i needed to set the record. In my opinion it's not really logical.

    Where did i go wrong in finding the solution of what method do i need to use to find a solution to this problem in the documentation?

Thread Participants: 1