0

リストアイテムがタップされたときに呼び出されるリストのコントローラー関数があります。この関数内で、ボタンコンポーネントのテキストを次のように更新しようとしています。

var button = this.getPopupButton();
//reference popupButton is set within controller
button.setText('Test');

この機能は機能しているようでconsole.info(button.getText());、更新を報告していますが、UI 内のテキストは構成で設定されたデフォルトのままです。

これはバグですか?それとも、ここで何か間違ったことをしていますか?

これらのボタンは、セグメント化されたボタン オブジェクト内にあります。

items: [
                {
                    xtype: 'segmentedbutton',
                    flex: 1,
                    allowDepress: true,
                    layout: {
                        align: 'stretchmax',
                        pack: 'center',
                        type: 'hbox'
                    },
                    items: [
                        {
                            xtype: 'button',
                            flex: 2,
                            id: 'PopUpButton',
                            text: 'Pop up test!'
                        },
                        {
                            xtype: 'button',
                            flex: 1,
                            id: 'Mini',
                            ui: 'action',
                            text: 'Mini test!'
                        }
                    ]
                }
            ]

更新: これらのボタンがデータリスト ツールバー内のセグメント化されたボタンであることを知っておくと役立つ場合があります。以下の完全なコードを参照してください。

Ext.define('TestApp.view.ItemList', {
extend: 'Ext.dataview.List',
alias: 'widget.ItemList',

config: {
    loadingText: 'Loading items...',
    store: 'ItemStore',
    cls: [
        'ItemList'
    ],
    itemTpl: Ext.create('Ext.XTemplate', 
        '<div>{itemData}</div>',
    ),
    plugins: [
        {
            xtype: 'component',
            refreshFn: function(plugin) {
                //console.info('pull to refresh!');

                var store = plugin.up().getStore();

                console.log(store);
            },
            itemId: 'PullToRefresh',
            loadingText: 'Loading...',
            pullRefreshText: 'Pull down to refresh...',
            releaseRefreshText: 'Release to refresh...',
            snappingAnimationDuration: 200,
            type: 'pullrefresh'
        },
        {
            autoPaging: true,
            loadMoreText: 'Load more...',
            noMoreRecordsText: 'No more data in feed',
            type: 'listpaging'
        }
    ],
    items: [
        {
            xtype: 'toolbar',
            docked: 'top',
            id: 'MediaToolbar',
            ui: 'light',
            zIndex: 3,
            items: [
                {
                    xtype: 'button',
                    flex: 1,
                    cls: 'SourceSelectButton',
                    id: 'SourceSelectButton',
                    minWidth: '',
                    width: 83,
                    iconCls: 'ItemSource1',
                    text: ''
                }
            ]
        },
        {
            xtype: 'toolbar',
            docked: 'top',
            height: '45px',
            id: 'FeedSelectorBar',
            ui: 'light',
            zIndex: 3,
            items: [
                {
                    xtype: 'segmentedbutton',
                    flex: 1,
                    id: 'FeedSelectorButtons',
                    allowDepress: true,
                    layout: {
                        align: 'stretchmax',
                        pack: 'center',
                        type: 'hbox'
                    },
                    items: [
                        {
                            xtype: 'button',
                            flex: 2,
                            id: 'PopUpButton',
                            text: 'Pop up test'
                        },
                        {
                            xtype: 'button',
                            flex: 1,
                            id: 'TesterButton',
                            ui: 'action',
                            text: 'Latest'
                        }
                    ]
                }
            ]
        }
    ]
}

});

更新 #2: を使用してコンソールでさらにテストした後、データビューリスト/ツールバー内に配置されたものを除くExt.ComponentQuery.query()、アプリケーションのすべてのボタンを操作できることがわかりました。

4

2 に答える 2

1

次の変更を試してみてください。これは私にとってはうまくいっています:-

  1. 分割されたボタンに「 id」を与えます。

        {
                xtype: 'segmentedbutton',
                id: 'hii',   // give id to your segmented button
                allowDepress: true,
                layout: {
                    align: 'stretchmax',
                    pack: 'center',
                    type: 'hbox'
                },
                items: [
                    {
                        xtype: 'button',
                        id: 'PopUpButton',
                        text: 'Pop up test!'
                    },
                    {
                        xtype: 'button',
                        id: 'Mini',
                        ui: 'action',
                        text: 'Mini test!'
                    }
                ]
            }     
    
  2. リストの「itemtap 」のコントローラー内でこのコードを使用します。

       var button = Ext.getCmp('hii');  // use your segmented button id here
       button.getAt(1).setText('Test');
    
于 2012-11-02T05:56:24.980 に答える
0

この問題はExt.dataview.ListExt.panelコンテナに移動することで解決されました。これは sencha touch 2.0.1.1 のバグのようです。dataview.List ツールバー コンポーネント内で操作したすべての要素は、コンソールでは更新済みとしてレポートされますが、UI では更​​新済みとして表示されません。Chrome、Safari、および phonegap プロジェクトとしてパッケージ化された Android デバイスの両方で同じ問題が発生しました。

于 2012-11-03T05:09:04.170 に答える