日期:2014-05-20  浏览次数:20589 次

struts2+Ext 显示网格
我的js代码如下:
/**
 * @author fox
 */
Ext.onReady(function(){
//Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';
//Ext.QuickTips.init();
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
sm,
{header:'姓名',dataIndex:'stuName',sortable:true},
{header:'学号',dataIndex:'stuNum',sortable:true},
{header:'性别',dataIndex:'stuSex',renderer:function(value){
if(value=='男'){
return "<span style='color:red;font-weight:bold;'>男</span>";
}else{
return "<span style='color:green;font-weight:bold;'>女</span>";
}
}}, //增加性别
{header:'年龄',dataIndex:'stuAge'},
{header:'电子信箱',dataIndex:'email'}
]);
var store = new Ext.data.Store({
  proxy: new Ext.data.HttpProxy({url:'http://localhost:8000/Student/JsonPlugin.action'}),
reader: new Ext.data.JsonReader({root: 'root'}, 
[
'stuName','stuNum','stuSex','stuAge','email',
{name: 'stuName',mapping:'stuName',type:'string'},
{name: 'stuNum',mapping:'stuNum',type:'string'},
{name: 'stuSex',mapping:'stuSex',type:'string'},
{name: 'stuAge',mapping:'stuAge',type:'int'},
{name: 'email',mapping:'email',type:'string'}
])
});


var grid = new Ext.grid.GridPanel({
store: store,
sm: sm,
cm: cm,
width:700,
height:280
});
//el:指定html元素用于显示grid
grid.render('grid');
});

我在页面可以显示当前这样的Grid,标题什么都可以显示,就是没有数据显示出来,在红色链接区域http://localhost:8000/Student/JsonPlugin.action 单独测试是完全可以返回JSON数据的,在Ext一结合就不能运行该请求,用debug测试无法进去该方法,请各位帮我解决下,谢谢啦,我也是刚接触,急用.

------解决方案--------------------
帮顶啦!
------解决方案--------------------
Store 
autoLoad:true

触发Store.load()
------解决方案--------------------
学习了