Results 1 to 7 of 7

Thread: Cannot rely on panel.body.dom.innerHTML for panel's HTML

  1. #1
    Sencha User
    Join Date
    Mar 2014
    Posts
    14
    Answers
    1

    Default Answered: Cannot rely on panel.body.dom.innerHTML for panel's HTML

    I've seen a number of answers on this forum dating back to 2011/12 stating that, in order to get a panel's HTML, it is as easy as

    Code:
    panel.body.dom.innerHTML
    I'm on ExtJS 4.2.1 and tried this but it returned HTML that included an outerCt span and innerCt div before the actual HTML I'd set when configuring the panel. To get at the actual HTML entails a couple more lines not unlike the following, but what I wish is that, since I can set the config, I should be able to get it back with a simple method call such as getHtml():

    Code:
    panelHtml = (function (panel) {
        var panelInnerCtId = panel.body.dom.id.replace('-body', '-innerCt');
        return Ext.dom.Query.selectNode("#" + panelInnerCtId).innerHTML;
    })(myPanel);

  2. My use case is irrelevant. Not providing a simple way to retrieve a panel's HTML is a deficiency. However since relying on innerCt may be "inevitable (sic) unreliable" I present the following solution:

    Code:
    panelHtml = (function (panelArg) {
        var panelInnerCtId = panelArg.body.dom.id.replace('-body', '-innerCt');
        var panelInnerCtEl = Ext.dom.Query.selectNode("#" + panelInnerCtId);
        
        if (panelInnerCtEl) {
            return panelInnerCtEl.innerHTML;
        }
        else {
            return panel.body.dom.innerHTML;
        }
    })(panelArgIn);

  3. #2
    Sencha User
    Join Date
    Mar 2014
    Posts
    14
    Answers
    1

    Default

    So has anybody else had to dig deeper into a nested DOM structure to get an "innerCt" corresponding to the body, or am I possibly doing something wrong? Thanks in advance.

  4. #3
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    In majority of cases you don't need html in Ext application, why and what for it is needed in you case? Where the panel body content comes from?

    It is inevitable unreliable as for some layouts innerCt is used but for some not.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  5. #4
    Sencha User
    Join Date
    Mar 2014
    Posts
    14
    Answers
    1

    Default

    My use case is irrelevant. Not providing a simple way to retrieve a panel's HTML is a deficiency. However since relying on innerCt may be "inevitable (sic) unreliable" I present the following solution:

    Code:
    panelHtml = (function (panelArg) {
        var panelInnerCtId = panelArg.body.dom.id.replace('-body', '-innerCt');
        var panelInnerCtEl = Ext.dom.Query.selectNode("#" + panelInnerCtId);
        
        if (panelInnerCtEl) {
            return panelInnerCtEl.innerHTML;
        }
        else {
            return panel.body.dom.innerHTML;
        }
    })(panelArgIn);

  6. #5
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    Well, I'm with Ext since 2007, written, consulted and supervised many big apps development and during all this time I've never seen that necessity of getting panel's body html.

    Ext normally generates the html, not analyzes/uses the html generated elsewhere.

    Don't take me wrong, I'm not saying that your requirement is not valid or that you don't have a use for it.

    You might be interested in reading this: Changing the viewpoint to Ext
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  7. #6
    Sencha User
    Join Date
    Mar 2014
    Posts
    14
    Answers
    1

    Default

    Hi Saki, I've been using ExtJS the vast majority of the time since Jan 2009, probably 50 of the last 64 months, and sure this is the first time that I need to get a panel's HTML, but others have been asking for this ability and it doesn't seem to be unreasonable that this should be able to do in an easy and reliable manner. I'm hoping my own accepted answer helps somebody.

    Here are some of those other questions regarding this:

    http://www.sencha.com/forum/showthre...tml-from-panel
    http://stackoverflow.com/questions/1...panel-in-extjs

  8. #7
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Answers
    512

    Default

    Maybe it is worth a feature request then.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •