`

GridPanel insert or remove

EXT 
阅读更多
//定义Grid中的行对象
var Student = Ext.data.Record.create([{
			name : 'id',
			mapping : 'id',
			type : 'int'
		}, {
			name : 'name',
			mapping : 'name',
			type : 'string'
		}, {
			name : 'sex',
			mapping : 'sex',
			type : 'string'
		}, {
			name : 'birthday',
			mapping : 'birthday',
			type : 'string'
		}, {
			name : 'by1',
			mapping : 'by1',
			type : 'string'
		}]);

//触发事件,如:添加成功后
var onAddSuccess = function(form, action) {
	var store = grid.getStore();
	var student = new Student({
				id : action.result.stuid,
				name : form.findField('name').getValue(),
				sex : form.findField('sex').getValue(),
				birthday : form.findField('birthday').getValue(),
				by1 : form.findField('by1').getValue()
			});
	store.insert(0, [student]);
	if (store.data.length > 10) {
		store.remove(store.getAt(store.data.length - 1));
	}
	Ext.MessageBox.alert("提示", "插入成功!");
	window_add.hide();
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics