62,046
社区成员
发帖
与我相关
我的任务
分享
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);
}
}
});