请教一下,添加数据后怎么刷新数据?新手学习Extjs
本帖最后由 showbo 于 2013-09-07 21:33:06 编辑
Ext.define('Ext.me.Panel', {extjs
extend: "Ext.panel.Panel",
anchor: '100% 100%',
layout: 'fit',
title: "测试",
csStore: null,
csColumn: null,
csGridPanel: null,
initComponent: function () {
var me = this;
var btnSearch = Ext.create('Ext.Button', {
text: "查询"
});
var btnAdd = Ext.create('Ext.Button', {
text: "新增"
});
var btnDelete = Ext.create('Ext.Button', {
text: "删除"
});
var btnUpdate = Ext.create('Ext.Button', {
text: "修改"
});
btnSearch.on("click", function () { me.searchOn(); });
btnAdd.on("click", function () { me.AddOn(); });
var barButton = Ext.create('Ext.toolbar.Toolbar', {
border: true,
items: [btnSearch,"-", btnAdd , "-", btnUpdate, "-", btnDelete],
split: true
});
me.tbar = barButton;
me.csStore = Ext.create('Ext.data.Store', {
proxy: {
type: 'ajax',
url: "../Person/GetMain",
reader: {
type: 'json'
}
},
fields: [
{ name: 'Product', type: 'string' },
{ name: 'Version', type: 'string' },
{ name: 'Description', type: 'string' },
]
});
me.csColumn = [
Ext.create('Ext.grid.RowNumberer', { text: '行号', width: 45 }),
{ text: '游戏', dataIndex: 'Product' },
{ text: '版本', dataIndex: 'Version' },
{ text: '描述', dataIndex: 'Description' },
];
var page = new Ext.PagingToolbar({
id: 'listPagingtoolbar',
store: me.csStore,
dock: 'bottom',
displayInfo: true
});
me.csGridPanel = Ext.create('Ext.grid.Panel', {
region: 'center',
columns: me.csColumn,
store: me.csStore,
dockedItems: ,
loadMask: { msg: '正在加载数据,请稍侯……' }
});
me.items = [me.csGridPanel];
me.superclass.initComponent.call(this);
},
searchOn: function () {
var me = this;
me.csStore.load();
},
AddOn: function () {
var win = new Ext.Window({
title: "添加记录窗口",
width: 347,
height: 250,
iconCls: "center_icon",
items: [{
xtype: "form",
id: "form1",
height: "250",
borderStyle: "padding-top:3px",
frame: true,
defaultType: "textfield",
labelAlign: "right",
labelWidth: 57,
defaults: {
allowBlank: false, width: 200
},
items: [
{ fieldLabel: "游戏", id: "Product", blankText: "名称" },
{ fieldLabel: "版本", id: "Version", blankText: "版本", xtype: "numberfield" },
{ fieldLabel: "描述", id: "Description" },
]
}],
buttons: [
{
xtype: "button",
text: "确定",
handler: function () {
if (!Ext.getCmp("form1").getForm().isValid()) {
alert("您输入的信息有误,请重新输入...");
return false;
}
var product = Ext.getCmp("Product").getValue("");
var version = Ext.getCmp("Version").getValue("");
var description = Ext.getCmp("Description").getValue("");
Ext.Ajax.request({
url:'http://localhost:6538/Person/Test?para=add',
params: {
"Product": product,"Version": version ,"Description":description
},
success: function (reponse, option) {
????
alert("添加成功!");
},
failure: function () {
alert("添加失败!");
}
});
}
},
{
xtype: "button",
text: "取消",
handler: function () {
Ext.getCmp("Product").setValue("");
Ext.getCmp("Version").setValue("");
Ext.getCmp("Description").setValue("");
}
}
]
});
win.show();
}
});
Ext.onReady(function () {
Ext.create("Ext.me.Panel").render(Ext.getBody());
});