0

私はSenchaTouchを使うのはまったく初めてです。サイドバーとマップペインを備えたアプリを作成しています。ユーザーがサイドバー領域の[マップの表示]ボタンをクリックすると、マップはその場所の中央に配置されます。私が問題を抱えているのは、ハンドラー関数からtpl変数にある{lat}プロパティと{lon}プロパティにアクセスする方法がわからないことです。これが些細な質問である場合はお詫びしますが、私は困惑しています。

Ext.define('Admin.view.Details',
{
extend: 'Ext.Panel',
xtype: 'details',

config:
{
    styleHtmlContent: true,
    scrollable: 'vertical',
    title: 'Individual',
    tpl:
    [
        'Account Number: {comid}',
        '<br />',
        'Address: ',
        '{address} <br />',
        '{lat},{lon}',
    ],

    items:
    [
        {
            title: 'Utilities',
            items:
            [
                {
                    xtype: 'selectfield',
                    label: 'Utility Type',
                    options: 
                    [
                        {text: 'Electricity', value: 'U1'},
                        {text: 'Water', value: 'U2'},
                        {text: 'Gas', value: 'u3' },
                    ],

                    id: 'utilityType',
                },
                {
                    xtype: 'selectfield',
                    label: 'Coverage Area',
                    options: 
                    [
                        {text: 'Subdivision', value: 'a1'},
                        {text: 'Zipcode', value: 'a2'},
                        {text: 'County', value: 'a3' },
                    ],

                    id: 'areaType',
                },
                {
                    xtype: 'button',
                    text: 'Show Map',
                    ui: 'round',
                    padding:3,
                    margin:10,
                    id:  'mapsBTN',
                    handler: function() {

                        olMap.setCenter(new OpenLayers.LonLat(lon, lat).transform
                        (
                            new OpenLayers.Projection("EPSG:4326"),
                            olMap.getProjectionObject()
                        ), 16);

                    }
                },
            ]
        },
    ]
}
});
4

2 に答える 2

1

ビューとボタンへの参照を追加してビューのコントローラーにハンドラーを実装しitemtap、ボタンのイベントのリスナーを追加するか、ビューのコンストラクターメソッドに実装する必要があります。

Ext.define('Admin.view.Details',{
  extend: 'Ext.Panel',
  xtype: 'details',

  config:{
    ...
  },

  constructor: function() {
    this.callParent(arguments);

    var me = this;

    this.child('#mapsBTN').setHandler(function() {
      me.getTpl(); // Here's your tpl config object
    });
  }
});

これが役に立ったことを願っています

于 2012-11-10T21:21:18.737 に答える
0

getter を使用して、config オブジェクト内の任意の変数を取得できます。

this.getTpl(); //returns tpl variable

thisまた、あなたの見解を指摘しなければならないことに注意してくださいAdmin.view.Details

于 2012-11-09T14:45:46.100 に答える