一个ext的grid分页栏显示不出来

caishaolang caishaolang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
//=======================这个是ext代码=========================

<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();// 浮动信息提示

Ext.BLANK_IMAGE_URL = "@{'public/javascripts/resources/images/default/s.gif'}";

//装载数据
var ds = new Ext.data.Store({

//数据源
proxy : new Ext.data.HttpProxy({
url : '@{AdminPrograma.index()}'
}),

reader : new Ext.data.JsonReader(
{
//数据总数
totalProperty : 'totalProperty',
//数据
root : 'root'
},
[
//列
{name: 'id'},
{name: 'name'}
]
)
});

// 加载首页数据
ds.load({
params :
{
start : 0,//当前页数
limit : 10//每页显示的数量
}
});

//定义复选框
var sm = new Ext.grid.CheckboxSelectionModel();

//列名
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
sm,// 添加复选框?
{
header : '编号',
dataIndex : 'id'
},
{
header : '姓名',
dataIndex : 'name'
}
]);

var grid = new Ext.grid.GridPanel({
id : 'student-grid',// 设置标识ID,方便以后引用!

title : '人员信息管理?',// 标题

renderTo : 'grid',// 显示表格的地方显示表格的地方

sm : sm,// 复选框

cm : cm,// 列模型

ds : ds,// 数据源

stripeRows : true,// 加上行条纹

loadMask : true,// 加载数据时遮蔽表格

border : true,// 加上边框

frame : true,// 显示天蓝色圆角框


stripeRows:true,

loadMask:true,

autoExpandColumn:'date',

autoHeight:false,

width : 700,

height : 400,

x : 1,// 设置初始位置横坐标?

y : 1,// 设置初始位置纵坐标?

collapsible : true, // 面板可以折叠

// 表格底部分页工具栏
bbar: new Ext.PagingToolbar({
pageSize:10,
store:ds,
displayInfo:true,
displayMsg:'显示第{0}条 到 {1}条记录,一共 {2} 条',
emptyMsg:"没有记录"
}),

//让列充满表格
viewConfig:{
forceFit:true ,
enableRowBody: true ,
scrollOffset:15,
displayInfo: true,
columnsText:'显示的列'
}
});
});
</script>


//=======================这个是后台 java=========================

public static String index(Integer start, Integer limit){

List<Product> products = Product.findAll();
String root ="root:[";
String totalProprerty = "totalProperty : 100";
String ds = "";
for (Product product : products) {
root += "{id:'" + product.getId() + "', name:'" + product.getName() +"'},";
}
//删除最后逗号 并加上中括号
root = root.substring(0, root.length() - 1) + "]";

ds = "{" + totalProprerty + "," + root + "}";

Logger.debug(ds);

return ds;
//输出时这样的 {totalProperty : 100,root:[{id:'17', name:'砖石手表'},{id:'18', name:'釜山手表'}]}
}


结果效果变成这样了
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
caishaolang
Web 开发 81,108 成员 341,721 内容