1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Vote Rating
    0
    kenzominang is on a distinguished road

      0  

    Default Why this tpl doesn't work?

    Why this tpl doesn't work?


    I am trying to use template in a panel. The template trigger is come from another grid item selection. But this code doesn't work....

    What is wrong with my code?
    Just simple copy/paste my code to run...
    Anyone, would you please fix this for me?

    HTML Code:
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
    <script type="text/javascript" src="extjs/ext-all-debug.js">
    </script>
    <script type="text/javascript">
        Ext.onReady(function () {
        
        Ext.create('Ext.data.Store',{
            storeId: 'letterStore',
            fields: ['TitleLetter','LetterType'],
            data: {
            'items': [
                { 'TitleLetter' : 'Keterangan', 'LetterType' : 'Not My Type'},
                { 'TitleLetter' : 'Dua', 'LetterType' : 'Yes This is my Type' }
            ]
            },
            proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
            }
        });
        
        
        var panel = Ext.create('Ext.panel.Panel',{
            title: 'Testing',
            renderTo: Ext.getBody(),
            items: [
            {
                xtype: 'gridpanel',
                title: 'Grid For TPL',
                bodyPadding: 5,
                listeners: {
                itemclick: function(selModel, record, index, options){
                    
                    var detailPanel = this.child('#detailPanel');
                    detailPanel().update(record.data);
                }
                },
                store: Ext.data.StoreManager.lookup('letterStore'),
                width: 300,
                height: 300,
                columns: [
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'TitleLetter',
                    text: 'Judul Surat'
                },
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'LetterType',
                    text: 'Tipe Surat'
                },
    
                ]
            },
            {
                xtype: 'panel',
                itemId: 'detailPanel',
                title: 'Show TPL',
                tpl: ['I am trying to use TPL {TitleLetter}']
            },
            
            
            ]
        
        
        });
        
        
        
        });
    
    </script>
    </head>
    <body>
    </body>
    </html>

  2. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    514
    Vote Rating
    82
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    There are a few problems, but easily fixable.

    First, your selector in the itemclick handler is incorrect. Since "this" is in the scope of the handler (which will be the grid), the selector is currently trying to find a child of the gridpanel with an id of "detailPanel". Obviously, that doesn't exist.

    So to fix that, you could easily do something like:

    Code:
    var detailPanel = this.up('panel').down('#detailPanel');
    From the grid, you get the parent panel, and then from there, drill down to the correct child.

    The next issue is on the next line. You have "detailPanel()", but that's not a method. Change it to:

    Code:
    detailPanel.update( record.data );
    Here's an example: http://jsfiddle.net/existdissolve/C247d/

    Finally, you might want to clean up the hanging commas that you have after the second grid column and the last panel. These will wreak havoc if you try to compress this.

    Good luck!

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Location
    uk
    Posts
    7
    Vote Rating
    0
    Michael H is on a distinguished road

      0  

    Default


    maybe the life of it is over now you may try replacing it now.....
    .

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar