English 中文(简体)
how to make a "MVC Application" with extjs 4.0 beta 3?
原标题:
  • 时间:2011-04-19 08:04:45
  •  标签:
  • extjs
  • extjs4

Is there someone here who made a MVC application using EXTJS 4 BETA 3? and works fine?? please help me how?, ..

I have followed step by step here .. and @Abdel Olakara help

but there is still an error ... here my firebug

[Ext.Loader] Synchronously loading  AM.controller.Users ; consider adding  
Ext.require( AM.controller.Users ) above Ext.onReady  

[Ext.Loader] Synchronously loading  AM.store.Users ; consider adding  
Ext.require( AM.store.Users ) above Ext.onReady

this.getView( Viewport ) is null

When i read this at the forum ... there are still some bug with MVC guide ...

so, if you ever make it works.. how?

this is my Application.js :

Ext.Loader.setConfig({enabled:true}); 
Ext.create( Ext.app.Application , {
    name:  AM ,

    controllers: [
         Users 
    ],

    views: [
         user.List 
    ],

    launch: function() {
        Ext.create( Ext.container.Viewport , {
            layout:  fit ,
            items: {
                xtype:  userlist 
            }
        });
    }
});

i m trying to learn MVC in Extjs... sorry if my english bad..

最佳回答

Well, I think I should take back my words! I had some success after going through sencha blog. And finally, got my MVC "Skeleton" running!

Here is the working code:

Ext.Loader.setConfig({enabled:true});
Ext.create( Ext.app.Application , {
    name:  AM ,
    autoCreateViewport: false,
    controllers: [],

    launch: function() {
        Ext.create( Ext.container.Viewport , {
            layout:  fit ,
            items: [
                {
                    xtype:  panel ,
                    title:  Users ,
                    html :  List of users will go here 
                }
            ]
        });
    }
}); 

Please note that, the code is very minimal and have removed the common errors reported in forums and here. The next step would be to start playing with this code and add controllers, views etc onto it!

I will keep updating this answer going forward.


Update: The first two error mentioned are not actually errors. They are warnings and application works fine even if they display these warnings. The third error you mentioned is a stopper!

Solution to Viewport problem Here are two ways to solve it.

  1. Use the autoCreateViewport: false, property and define your viewport (I see that you have defined your viewport in launch method)
  2. Create a Viewport.js and save it in view folder. In this case, I felt my launch method empty and moved the viewport code to Viewport.js file. But I do get an error:

    Uncaught TypeError: Cannot call method create of null

问题回答

I do use ExtJS 4.1.

In my code [Ext.Loader] Synchronously loading OOO.store.News ; consider adding
Ext.require( OOO.store.News ) above Ext.onReady
warning message was invoked if I place

stores: [
     News ,
],

in my app/Application.js file instead of app/controller/OOO.js file.

So put stores:[], in controller file.





相关问题
ExtJS load form items/fields from database

I am using ExtJS 3 here. I would like to populate a formpanel from database with fields to be submitted. Basically, I don t know witch fields my form will have and I want to generate all formpanel ...

How to use Ext JS for role based application

I am planning to use Ext JS for a large application. The application s features are role based. When user login, they only see menu and screen features related to them. My server side technology will ...

Dynamically adding a TabPanel to a Panel Region

I have a Panel layout with a TreePanel in one region. A user clicks on an node in the tree and a TabPanel should be displayed in another region with information, editing tools etc. for that tree node....

How to embed Json result within Extjs Panel?

I have some issues with Json result and embed it within the html of the Extjs Panel. Here s that I have managed to get so far. myPanel is embedded within a mainPanel, and I have some shows/hide of ...

Ajax data update. Extjs

I need to keep certain data ( in a grid) up to date and was gonna do a poll to the server every 15 seocnds or so to get the data and refresh the grid, however it feels a bit dirty ( the grid will have ...

Better way to call superclass method in ExtJS

All the ExtJS documentation and examples I have read suggest calling superclass methods like this: MyApp.MyPanel = Ext.extend(Ext.Panel, { initComponent: function() { // do something MyPanel ...

Merged Headers in Ext JS Grid

Is it possible to have two headers in Ext JS grids? I have to show my grid as grouped data.. for example product types and products. In my case I need a grid like this: Field | Product Type A ...

热门标签