问题是这样的,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);
}
}
});
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);
}
}
});
當我自己要設計高深而複雜的程式時,
我是不會用 Asp.Net 內建的程序,
我自己寫一個類別庫來控制,
我的做法是這樣的,
aspx 處理該頁數據,
js 顯示 aspx 輸出的資料,
使用者按下頁數時就用 Get 方式傳出頁數給 aspx,
aspx 處理該頁 SQL 中的筆數,
用 response.write 方式回應 js,
js 再用 ul,li 顯示資訊。
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写
mystore.load({ params: { start: 0, limit: 10} }); start和limit 是扔过去的两个参数,要接受这两个参数,自己写分页:) 。 Thank you,Everybody~