1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    98
    Vote Rating
    3
    grizzly21 is on a distinguished road

      0  

    Default Answered: Get html content of a panel

    Answered: Get html content of a panel


    Hi,

    I want to do a very simple thing:
    I have a panel that has a template, I call setData on it:

    Ext.getCmp("myPanel").setData( myData );

    Then how do I get the html that was rendered using the panels template?

    One way to do it is:
    Ext.getCmp("myPanel").getTpl().apply( myData )

    but obviously this is slow and unnecessary. I see a getHtml() method on the panel in the docs, but it returns null..

    thanks

  2. Hi,

    Code:
    var html = <your_panel>.getInnerHtmlElement().dom.innerHTML;
    PS: Please stay away from "Ext.getCmp()".

  3. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,395
    Answers
    148
    Vote Rating
    23
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Hi,

    Code:
    var html = <your_panel>.getInnerHtmlElement().dom.innerHTML;
    PS: Please stay away from "Ext.getCmp()".
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  4. #3
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    98
    Vote Rating
    3
    grizzly21 is on a distinguished road

      0  

    Default


    Thanks this worked.

    I could use itemId with mycontainer.down("#itemId").

    Or is there anything else I could do?

  5. #4
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,395
    Answers
    148
    Vote Rating
    23
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Quote Originally Posted by grizzly21 View Post
    Thanks this worked.

    I could use itemId with mycontainer.down("#itemId").

    Or is there anything else I could do?
    Yes, it's definitively better!
    Otherwise you could simply set a reference to your component directly inside the controller "refs" config.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  6. #5
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    98
    Vote Rating
    3
    grizzly21 is on a distinguished road

      0  

    Default


    ok, thanks.

Thread Participants: 1