admin管理员组

文章数量:1401365

I have a extJS window. I want to display some text or message which may be response of some server data. Can any body help me how to display ytext on ext JS window. What I need to edit in my code below.

var MyWin = Ext.create('Ext.window.Window', {
            title: "My Window",
            height: 200,
            width: 400,
            layout: 'fit',
        });
        MyWin.show();

Thanks for help.

I have a extJS window. I want to display some text or message which may be response of some server data. Can any body help me how to display ytext on ext JS window. What I need to edit in my code below.

var MyWin = Ext.create('Ext.window.Window', {
            title: "My Window",
            height: 200,
            width: 400,
            layout: 'fit',
        });
        MyWin.show();

Thanks for help.

Share Improve this question asked Nov 25, 2016 at 9:23 DavidDavid 4,28311 gold badges41 silver badges90 bronze badges 3
  • this might help – Kevin Kloet Commented Nov 25, 2016 at 9:25
  • html text or simple text? – LellisMoon Commented Nov 25, 2016 at 9:31
  • Happy if you can show both – David Commented Nov 25, 2016 at 9:33
Add a ment  | 

2 Answers 2

Reset to default 4

Personally I preferred show server errors whit a simple window and html in it, like And-y shows you can set html of a window, you can do simply that using a function everywere like this:

 var errorShow = function (text) {
        Ext.create({
            xtype: 'window',
            title: 'Response error',
            modal:true,
            width: 200,
            height: 200,
            html:text,
            scrollable: 'y'
        }).show();
    };
    errorShow('<div style="text-align:center;"><h1>Server error</h1>'+
    '<text style="color:red; font-size:1.4em;">404 not found</text><br/>'+
    '<text style="color:blue;">www.error./img.jpg</text><br/>'+
    '<text style="color:blue;">Error requiring image</text></div>');

here is a fiddle to show you.

Remember that you should use the same function during every error, setting dimentions on your need. A modal window should be used, to ensure that it will be closed.

You can just use the html config to display plain text or html formated text in the Ext.window.Window and any other Ext.Component.
From the ExtJs 5.1.3 documentation html config:

An HTML fragment, or a Ext.dom.Helper specification to use as the layout element content. The HTML content is added after the ponent is rendered, so the document will not contain this HTML at the time the render event is fired. This content is inserted into the body before any configured contentEl is appended. Defaults to: ''

The working code looks like:

var MyWin = Ext.create('Ext.window.Window', {
    title: "My Window",
    height: 200,
    width: 400,
    layout: 'fit',
    html: "with some plain text or <p> some html</p>"
});
MyWin.show();

Here is a working fiddle with the code above.

本文标签: javascriptHow to display plain text in ExtJsStack Overflow