开发者

How can I manipulate contents of an extjs panel as I can a DOM element?

In the following extJS page, when I click the button, the content of the HTML Div "buttonInfo" changes correctly.

I want to also change the contents of the panel that I created with extJS.

However, when I change the contents of the panel as I do the div, the whole panel is simply replaced.

How can I change the contents of my panel object from within my button's click handler?

before:

How can I manipulate contents of an extjs panel as I can a DOM element?

after:

How can I manipulate contents of an extjs panel as I can a DOM element?

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css">
        <style type="text/css">
            body {
                padding: 20px;
            }
            div#infoBox {
                margin: 10px 0 0 0;
                width: 190px;
                height: 100px;
                background-color: lightblue;
                padding: 10px;
            }
            div#content {
                margin: 10px 0 0 0;
            }
            div.x-panel-body {
                padding: 10px;
            }
        </style>
        <script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="ext/ext-all-debug.js"></script>
        <title>Simple extJS</title>
        <script type="text/javascript">
            Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';
            Ext.onReady(function(){

                Ext.get('buttonInfo').on('click', function(){
                    Ext.get('infoBox').update('This is the <b>new</b> content.');
                    Ext.get('panel1').update('new info');
                    //Ext.get('panel1').html = 'new info111'; //doesn't work
                    //panel1.html = 'new info222'; //开发者_如何学Godoesn't work
                });

                new Ext.Panel({
                    id: 'panel1',
                    renderTo: 'content',
                    width: '210px',
                    title: 'Extended Info',
                    html: 'original text',
                    collapsible: true
                });

            });            
        </script>
    </head>
    <body>
        <button id="buttonInfo">
            Show Info
        </button>
        <div id="infoBox">
        </div>
        <div id="content-wrapper">
            <div id="content"></div>
        </div>
    </body

>


Ext.get gives you the dom object, use Ext.getCmp instead so that it returns the Ext object back, then you can use the update method on the panel:

Try:

Ext.getCmp('panel1').update('new info');

Hope it helps.


Try:

var Data = 'new info'; panel1.overwrite(panel1.body, Data); panel1.doComponentLayout();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜