ExtJs Grid有关问题
ExtJs Grid问题!
这我的项目的结构
Model:
Ext.define("user",{
extend : 'Ext.data.Model',
fields : [
{name: 'name', type: 'string'},
{name: 'email', type: 'string'},
{name: 'phone', type: 'string'}
]
});
store:
Ext.create("Ext.data.Store",{
model : "user",
storeId : "usersStore",
/*data: [
{ name: 'Lisa', email: 'lisa@simpsons.com', phone: '555-111-1224' },
{ name: 'Bart', email: 'bart@simpsons.com', phone: '555-222-1234' },
{ name: 'Homer', email: 'home@simpsons.com', phone: '555-222-1244' },
{ name: 'Marge', email: 'marge@simpsons.com', phone: '555-222-1254' }
]*/
proxy : {
type: 'ajax',
url : './TestData.jsp',
reader: {
type: 'json',
root: 'users'
},
writer : {
type:"json"
}
},
autoLoad : true
});
Grid:
function(){
Ext.onReady(function(){
var s = Ext.data.StoreManager.lookup("usersStore");
window.alert(s.getCount());
Ext.tip.QuickTipManager.init();
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody(),
store: Ext.data.StoreManager.lookup("usersStore"),
width: 400,
height: 200,
title: 'Grid',
columns: [
{text: 'Name',sortable: true,dataIndex: 'name'},
{text: 'Email Address',sortable: true,dataIndex: 'email'},
{text: 'Phone Number',sortable: true,dataIndex: 'phone'}
]
});
})
})();
jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>My JSP 'TestData.jsp' starting page</title>
</head>
<body>
<%
System.out.print("{\"total\":\"3\", \"users\":[{ \"name\": \"Lisa\", \"email\": \"lisa@simpsons.com\", \"phone\": \"555-111-1224\"},{ \"name\": 'Bart', \"email\": \"bart@simpsons.com\", \"phone\": \"555-222-1234\" }]}");
这我的项目的结构
Model:
Ext.define("user",{
extend : 'Ext.data.Model',
fields : [
{name: 'name', type: 'string'},
{name: 'email', type: 'string'},
{name: 'phone', type: 'string'}
]
});
store:
Ext.create("Ext.data.Store",{
model : "user",
storeId : "usersStore",
/*data: [
{ name: 'Lisa', email: 'lisa@simpsons.com', phone: '555-111-1224' },
{ name: 'Bart', email: 'bart@simpsons.com', phone: '555-222-1234' },
{ name: 'Homer', email: 'home@simpsons.com', phone: '555-222-1244' },
{ name: 'Marge', email: 'marge@simpsons.com', phone: '555-222-1254' }
]*/
proxy : {
type: 'ajax',
url : './TestData.jsp',
reader: {
type: 'json',
root: 'users'
},
writer : {
type:"json"
}
},
autoLoad : true
});
Grid:
function(){
Ext.onReady(function(){
var s = Ext.data.StoreManager.lookup("usersStore");
window.alert(s.getCount());
Ext.tip.QuickTipManager.init();
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody(),
store: Ext.data.StoreManager.lookup("usersStore"),
width: 400,
height: 200,
title: 'Grid',
columns: [
{text: 'Name',sortable: true,dataIndex: 'name'},
{text: 'Email Address',sortable: true,dataIndex: 'email'},
{text: 'Phone Number',sortable: true,dataIndex: 'phone'}
]
});
})
})();
jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>My JSP 'TestData.jsp' starting page</title>
</head>
<body>
<%
System.out.print("{\"total\":\"3\", \"users\":[{ \"name\": \"Lisa\", \"email\": \"lisa@simpsons.com\", \"phone\": \"555-111-1224\"},{ \"name\": 'Bart', \"email\": \"bart@simpsons.com\", \"phone\": \"555-222-1234\" }]}");