GridPanel 分页问题.Ext 大侠 救命啊~~~~帮顶有分

Robinfu2013 2010-11-30 06:38:21
问题是这样的,GridPanel 能取到所有的值。但是分页无效。可以翻页。但是翻页数据无任何变化。都是所有数据。
mystore.load({ params: { start: 0, limit: 10} }); ←个人理解这句应该是加载的时候只加载部分数据吧?
还有PagingToolbar 的 pageSize 也设置了,就是控制不住...囧啊..各位大侠谁知道原因,告诉一声谢谢。
下面是代码

Ext.onReady(function () {
Ext.QuickTips.init();
//Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

//设置代理数据
var proxy = new Ext.data.HttpProxy({
url: '/action/S_MediaData.aspx',
method: 'GET'
});



// create the data store
var mystore = new Ext.data.Store({
proxy: proxy,
reader: new Ext.data.JsonReader({
root: 'topics',
totalProperty:'totalProperty',
id: 'ML_Autoid'
},['ML_Autoid', 'M_Name', 'A_ID', 'M_lv', 'Perfect'])
});
mystore.load({ params: { start: 0, limit: 10} });

//定义列
var colM = new Ext.grid.ColumnModel([
{ header: '编号', dataIndex: 'ML_Autoid', sortable: true },
{ header: '名称', dataIndex: 'M_Name' },
{ header: '地区', dataIndex: 'A_ID' },
{ header: '级别', dataIndex: 'M_lv' },
{ header: '状态', dataIndex: 'Perfect' },
{
header: '删除',
xtype: 'actioncolumn',
width: 50,
items: [{
icon: '/js/ext3.3/examples/shared/icons/fam/delete.gif', // Use a URL in the icon config
handler: function (grid, rowIndex, colIndex) {
var rec = mystore.getAt(rowIndex);
recid = rec.get('ML_Autoid');
Ext.MessageBox.show({
title: '删除 ' + rec.get('M_Name') + '?',
msg: '确定删除 ' + rec.get('M_Name') + ' 这条记录?',
buttons: Ext.MessageBox.YESNO,
fn: delRecord,
icon: Ext.MessageBox.QUESTION
});

},
tooltip: 'Sell stock'
}]
},
{
header: '更新',
xtype: 'actioncolumn',
width: 50,
items: [{
icon: '/js/ext3.3/examples/shared/icons/fam/application_go.png', // Use a URL in the icon config
handler: function (grid, rowIndex, colIndex) {
var rec = mystore.getAt(rowIndex);
alert("Sell " + rec.get('ML_Autoid'));
},
tooltip: 'Sell stock'
}]
}

]);

//create the gridpanel
var grid = new Ext.grid.GridPanel({
store: mystore,
stripeRows: true,
//autoExpandColumn: 'ML_Autoid', 自动填充字段
autoHeight : true,
bodyStyle : 'width:100%',
autoHeight: true,
cm: colM,
loadMask: true,
autoWidth : true,
border:false,
title: '媒体库管理',
// config options for stateful behavior
stateful: true,
viewConfig: {
forceFit: true
},
stateId: 'grid',
tbar : new Ext.Toolbar({
items : [{
id : 'btnAdd',
icon: '/js/ext3.3/examples/shared/icons/fam/add.gif',
text : "添加",
handler : function() {
Ext.MessageBox.alert("添加","做添加的操作");
}
}
]

}),

bbar: new Ext.PagingToolbar({

pageSize: 10,
store: mystore,
displayInfo: true,
displayMsg: '第{0} 到 {1} 条数据 共{2}条',
emptyMsg: "没有数据"

})
});

// render the grid to the specified div in the page
grid.render('grid-example');

function delRecord(btn)
{
if(btn=="yes"){
alert(recid);
}
}
});
...全文
131 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Robinfu2013 2010-12-01
  • 打赏
  • 举报
回复
今天自己搞明白了。四楼小妹妹最后一句说对了。
mystore.load({ params: { start: 0, limit: 10} }); start和limit 是扔过去的两个参数,要接受这两个参数,自己写分页:) 。 Thank you,Everybody~
flyerwing 2010-12-01
  • 打赏
  • 举报
回复
那个东西加几个参数就OK,大部分分页都是分页取数据的.
呀· 2010-12-01
  • 打赏
  • 举报
回复
bbar里要有doload事件
bbar: new Ext.PagingToolbar({
store: CarsJsonStore,
pageSize: 12,
displayInfo: true,
beforePageText: "第",
afterPageText: "/ {0}页",
firstText: "首页",
prevText: "上一页",
nextText: "下一页",
lastText: "尾页",
refreshText: "刷新",
displayMsg: "",
emptyMsg: "没有相关记录!",
doLoad: function(start) {
var o = {}, pn = this.paramNames;
o[pn.start] = start;
o[pn.limit] = this.pageSize;
this.store.load({ params: o });
}
}),
数据源'/action/S_MediaData.aspx'里获取数据的时候sql语句也要按分页的sql写
wuyq11 2010-11-30
  • 打赏
  • 举报
回复
samho321 2010-11-30
  • 打赏
  • 举报
回复
你是不是要做 Ajax 的資料分頁???

我也為自己的類別庫做了SQL分頁,

簡單說說概念,
當我自己要設計高深而複雜的程式時,
我是不會用 Asp.Net 內建的程序,
我自己寫一個類別庫來控制,
我的做法是這樣的,
aspx 處理該頁數據,
js 顯示 aspx 輸出的資料,
使用者按下頁數時就用 Get 方式傳出頁數給 aspx,
aspx 處理該頁 SQL 中的筆數,
用 response.write 方式回應 js,
js 再用 ul,li 顯示資訊。
xiatiandetonghua 2010-11-30
  • 打赏
  • 举报
回复
有难度,有深度,帮顶!

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧