2

コンボボックスオプションが選択されている場合、どうすればこのExt.Componentを再レンダリングできますか?

var searchForm = Ext.create('Ext.form.Panel', {
    width: 320,
    style: 'margin: 20px',
    renderTo: 'SearchPanel',
    style: {
        position: 'fixed',
        top: '0px',
        left: '865px'
    },
    items: [{
        xtype: 'combo',
        width: 300,
        labelAlign: 'right',
        fieldLabel: 'Subject Area',
        store: subjectAreaStore,
        valueField: 'id',
        displayField: 'value',
        typeAhead: true,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true,
        value: 'Account',

        listeners: {
            select: function (combo) {
                cmp.autoEl.src = '/' + combo.getValue() + '/2nd Iteration.htm';
                alert(cmp.autoEl.src);

                cmp.render();  // this does not work!
            }
        }  // listeners
    }]

});               


// create the cmp
var cmp = Ext.create('Ext.Component', {

    title: 'Data Models',
    style: {
        width: '100%',
        height: '750px'
    },

    autoEl : {
        tag : 'iframe',
        src : '/Account/2nd Iteration.htm'
    },

    renderTo: 'models'
});

更新:2012年10月23日:

これはまだ機能していません:

            listeners: {
                select: function (combo) {
                    cmp.autoEl.src = '/' + combo.getValue() + '/2nd Iteration.htm';
                    var the_iframe = cmp.getEl().dom;
                    the_iframe.contentWindow.location.reload();
                }
            }  // listeners
4

2 に答える 2

4

iframeを作成するための別のアプローチを提案します。コンポーネントのhtmlプロパティを使用し、autoel機能を使用する代わりに自分でhtmlを記述します(コンポーネントではこれを行わず、コンテナのみですが、同じように機能するはずです)...

var cmp = Ext.create('Ext.Component', {
    title: 'Data Models',
    style: {
        width: '100%',
        height: '750px'
    },
    renderTo: 'models',
    html: '<iframe src="/Account/2nd Iteration.htm"></iframe>'
});

次に、リスナーでこれを実行して更新します...

listeners: {
    select: function (combo) {
        cmp.update('<iframe src="/' + combo.getValue() + '/2nd Iteration.htm"></iframe>');
    }
}
于 2012-10-23T18:39:41.257 に答える
1

このrender()メソッドは、ExtJSによって作成(レンダリング)されたHTMLのみを処理します。そのiframeを自分で作成したので、自分で制御する必要があります。次のように、コンポーネントからDOM要素を取得できるはずです。

var the_iframe = cmp.getEl().dom;
the_iframe.contentWindow.location.reload();
于 2012-10-23T02:54:31.513 に答える