当我尝试在窗口(Ext.Window)中组合不同的组件(下拉列表,网格,按钮等)时,不显示网格。以下是代码:
<%@ 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: 'j.smith@netapp.com', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jim',lname:'Smith',email: 'jm.smith@netapp.com', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jane',lname:'Smith',email: 'j.smith@netapp.com', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jim',lname:'Smith',email: 'jm.smith@netapp.com', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jane',lname:'Smith',email: 'j.smith@netapp.com', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jim',lname:'Smith',email: 'jm.smith@netapp.com', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jane',lname:'Smith',email: 'j.smith@netapp.com', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jim',lname:'Smith',email: 'jm.smith@netapp.com', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jane',lname:'Smith',email: 'j.smith@netapp.com', uid: 'jsmith',isSup:false,upDate:'11-19-2012',upBy:'aaron@netapp.com' },
{ fname: 'Jim',lname:'Smith',email: 'jm.smith@netapp.com', uid: 'jmsmith',isSup:true,upDate:'11-23-2012',upBy:'aaron@netapp.com'}
],
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>
请告诉我,我做错了。或者让我知道,我如何在EXTJS中组合不同的组件。我不想在html体中的div标签中呈现不同的组件。
答案 0 :(得分:1)
删除网格配置中的initComponent
方法。如果您需要覆盖现有方法,请使用Ext.define
创建子类,以便callParent
按预期工作。
关于您的代码的几条评论(与您的问题无关):
创建商店并在同一配置对象中引用它是iffy。您应该在配置之外创建商店并使用store: "supUserStore"
而不是自己进行StoreManager查找。
网格列上的header
属性已弃用一段时间。首选属性称为text
。
您可以使用win.show()
配置,而不是在创建窗口后调用autoShow: true
。