views:

2566

answers:

2

Hi,

Please tell me why my window doesn't render. Below is the javascript that i am using

<link href="/Scripts/ext/resources/css/ext-all.css" rel="stylesheet" type="text/css"/>

    <script src="/Scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="/Scripts/ext/adapter/jquery/ext-jquery-adapter.js" type="text/javascript"></script>
    <script src="/Scripts/ext/ext-all.js" type="text/javascript"></script>




    <script type="text/javascript">
        $(function() {
            var viewport = new Ext.Viewport({
                items:[[
  {
    "minimizable": true,
    "maximizable": true,
    "title": "Hello World",
    "height": 300,
    "width": 400,
    "xtype": "window"
  }
]]
            });
        });
    </script>
+2  A: 

Why would you create a window as an item of a viewport like that? You don't do that.

Do:

Ext.onReady(function() {

var win = new Ext.Window({
  minimizable: true,
  maximizable: true,
  title: "Hello World",
  height: 300,
  width: 400
});

win.show();

});
Lloyd
I thought that extjs supports implicit rendering :( using xtypes. Isn't that the case?
Ali Kazmi
That is the case BUT a Window isn't supposed to be used as an item, the items of a viewport is supposed to things like a panel.
Lloyd
Why are windows handled like this :(. This is annoying :(
Ali Kazmi
Because it's a window, why would you want to create it as an inline item like that, you also have to explcitily show() a window which you can't do when declared like that.
Lloyd
i wanted to render the whole UI as a large Json object config written from server side inside a viewport. But that doesn't seem possible :(
Ali Kazmi
and as for the 'show' issue, i think that could be done by setting autoShow attribute to true ?
Ali Kazmi
That is true autoShow may eliminate show() but again I don't think you're meant to add a Window as an item. There's nothing stopping you from outputting JavaScript and using eval().
Lloyd
+1  A: 

I don't have enough reputation to comment above, but Lloyd is 100% correct. Windows float above the layout (position:absolute) whereas component items are rendered -into- the layout as nested parent/child node structures. If you look at the markup for a rendered Window, it is created at the document body level -- there is no relationship between it and any layout panels.

It may be a confusion over naming -- as Lloyd said, a Panel is what you actually want (and is what gets created by default when you add an item to a viewport). Panels function much like windows, but they are built into the layout structure instead of floating above it. If you really want a window, then use Lloyd's code.

bmoeskau