Anushree Acharjee
Anushree Acharjee

Reputation: 874

EXTJS4- Grid is not being displayed when its a component in window

when I am trying to combine different components(dropdown,grid,buttons etc) in an window(Ext.Window), grid is not being displayed. Following is the code:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Super User Access Management</title>
<link rel="stylesheet" href="http://cdn.sencha.io/ext-4.1.1-gpl/resources/css/ext-all.css">
    <script type="text/javascript" charset="utf-8" src="http://cdn.sencha.io/ext-4.1.1-gpl/ext-all.js"></script>
    <script type="text/javascript">

Ext.onReady(function () {
    Ext.define('SuperUser', {
        extend: 'Ext.data.Model',
        fields: [
            { name: 'fname', type: 'string' },
            { name: 'lname', type: 'string' },
            { name: 'email', type: 'string' },
            { name: 'uid', type: 'string' },
            { name: 'isSup', type: 'boolean' },
            { name: 'upDate', type: 'string' },
            { name: 'upBy', type: 'string' }
        ]
    });

    var win=new Ext.Window({
        title: 'Super User Access Management',
        border:false,
          items       : [  
          {
          xtype      : 'combo',
          fieldLabel : 'Module',
          value: 'Super Admin' ,
          store: ['Super Admin', 'Partner Contact Management', 'Partner Trainning Management'],
          listeners: {
              select: function(){
               alert('Hello module!');
              }
            }        
            },
            { 
                xtype: 'gridpanel',
                border: false,
                store: Ext.create('Ext.data.Store', {
                    storeId: 'supUserStore',
                    pageSize: 3,
                    model:'SuperUser',
                    data: [
                            { fname: 'Jane',lname:'Smith',email: '[email protected]', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'[email protected]' },
                            { fname: 'Jim',lname:'Smith',email: '[email protected]', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'[email protected]' },
                            { fname: 'Jane',lname:'Smith',email: '[email protected]', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'[email protected]' },
                            { fname: 'Jim',lname:'Smith',email: '[email protected]', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'[email protected]' },
                            { fname: 'Jane',lname:'Smith',email: '[email protected]', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'[email protected]' },
                            { fname: 'Jim',lname:'Smith',email: '[email protected]', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'[email protected]' },
                            { fname: 'Jane',lname:'Smith',email: '[email protected]', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'[email protected]' },
                            { fname: 'Jim',lname:'Smith',email: '[email protected]', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'[email protected]' },
                            { fname: 'Jane',lname:'Smith',email: '[email protected]', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'[email protected]' },
                            { fname: 'Jim',lname:'Smith',email: '[email protected]', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'[email protected]'}
                        ],
                    proxy: { type: 'memory', reader: { type: 'json', root: 'data',totalProperty:10} }
                }),
                selModel: Ext.create('Ext.selection.CheckboxModel'),
                columns: [
                          { header: 'First Name', dataIndex: 'fname' },
                          { header: 'Last Name', dataIndex: 'lname' },
                          { header: 'Email', dataIndex: 'email' },
                          { header: 'User ID', dataIndex: 'uid' },
                          { header: 'Super Admin', dataIndex: 'isSup' },
                          { header: 'Updated Date', dataIndex: 'upDate' },
                          { header: 'Updated By', dataIndex: 'upBy' }
                      ],
                      dockedItems: [{
                          xtype: 'pagingtoolbar',
                          store: Ext.data.StoreManager.lookup('supUserStore'),   
                          dock: 'bottom',
                          displayInfo: true
                      }],
                      initComponent: function () {
                          this.callParent(arguments);

                      }
                }

            ]
    });
    win.show();

}); 
    </script>
</head>
<body>

</body>
</html>

please please let me know, where I am doing wrong.Or let me know, How can i combine different components in EXTJS. I dont want to render different component in div tag in html body.

Upvotes: 1

Views: 126

Answers (1)

Eric
Eric

Reputation: 6995

Remove the initComponent method in your grid config. If you need to override existing methods, use Ext.define to make a subclass so that callParent works as intended.

A couple of comments about your code (not related to your problem):

  1. Creating your store and referring to it in the same config object is iffy. You should create the store outside of the config and use store: "supUserStore" instead of doing the StoreManager lookup yourself.

  2. The header property on grid columns has been deprecated for a while. The preferred property is called text.

  3. Instead of calling win.show() after creating the window, you can use the autoShow: true config.

Upvotes: 1

Related Questions