单击添加按钮时需要在网格中添加多个记录
Need to add the multiple records in grid when I click the add button?
当我单击按钮时,我必须将多个记录添加到网格中。但它每次只添加一条记录。也就是说,它添加一个记录;之后,它只能添加记录。
请注意,基于单选按钮检查编辑发生。
如果错误,任何人都可以纠正代码吗?
tbar: [
{
text: 'Add',
tooltip: 'Add Focus Market',
iconCls: 'icon-shift-add',
scope: me,
handler: function() {
addFocusMarket.call(this);
}
}
],
plugins: [ this.mcmRowEditing ],
viewConfig: {},
listeners: {
scope: me,
validateedit: function(editor, e) {
var searchval = Ext.getCmp('searchGroup').getValue();
if(searchval.search_type == "CityPair" ) {
console.log("city pair update..");
if(e.newValues.Origin !== e.originalValues.Origin ||
e.newValues.Destination !== e.originalValues.Destination ||
e.newValues.CabinClass !== e.originalValues.CabinClass ||
e.newValues.StartAvailability.getDate() !== e.originalValues.StartAvailability.getDate() ||
e.newValues.EndAvailability.getDate() !== e.originalValues.EndAvailability.getDate()) {
if(!e.newValues.Origin) {
App.mcmShowMessageBox({
title: 'Important',
message: 'Please set the Origin',
time: 2000
});
return false; }
if(!e.newValues.Destination) {
App.mcmShowMessageBox({
title: 'Important',
message: 'Please set the Destination',
time: 2000
});
return false; }
if(!e.newValues.CabinClass) {
App.mcmShowMessageBox({
title: 'Important',
message: 'Please enter a valid CabinClass',
time: 2000
});
return false; }
e.newValues.Origin = e.newValues.Origin.toUpperCase();
e.newValues.Destination = e.newValues.Destination.toUpperCase();
e.record.set('Origin', e.newValues.Origin);
e.record.set('Destination', e.newValues.Destination);
e.record.set('CabinClass', e.newValues.CabinClass);
e.record.set('StartAvailability', e.newValues.StartAvailability);
e.record.set('EndAvailability', e.newValues.EndAvailability);
App.mcmAddCityPair({
focusmarketRecord: e.record,
successCallback: function(obj) {
e.record.data = obj;
App.mcmFindCityPair(this.mcmSearchType, obj.Origin, obj.Destination,
obj.StartAvailability, obj.EndAvailability);
this.mcmHasChanges = true;
},
successScope: this,
failureCallback: App.mcmTabReload,
failureScope: App
});
}
}
else if(searchval.search_type == "IndividualFlights") {
console.log("flight number update..");
if(e.newValues.Origin !== e.originalValues.Origin ||
e.newValues.Destination !== e.originalValues.Destination ||
e.newValues.CabinClass !== e.originalValues.CabinClass ||
e.newValues.FlightNumber !== e.originalValues.FlightNumber ||
e.newValues.StartAvailability.getDate() !== e.originalValues.StartAvailability.getDate() ||
e.newValues.EndAvailability.getDate() !== e.originalValues.EndAvailability.getDate()) {
if(!e.newValues.FlightNumber) {
App.mcmShowMessageBox({
title: 'Important',
message: 'Please enter a valid FlightNumber',
time: 2000
});
return false; }
if(!e.newValues.Origin) {
App.mcmShowMessageBox({
title: 'Important',
message: 'Please set the Origin',
time: 2000
});
return false; }
if(!e.newValues.Destination) {
App.mcmShowMessageBox({
title: 'Important',
message: 'Please set the Destination',
time: 2000
});
return false; }
if(!e.newValues.CabinClass) {
App.mcmShowMessageBox({
title: 'Important',
message: 'Please enter a valid CabinClass',
time: 2000
});
return false; }
e.newValues.Origin = e.newValues.Origin.toUpperCase();
e.newValues.Destination = e.newValues.Destination.toUpperCase();
e.record.set('Origin', e.newValues.Origin);
e.record.set('Destination', e.newValues.Destination);
e.record.set('CabinClass', e.newValues.CabinClass);
e.record.set('FlightNumber', e.newValues.FlightNumber);
e.record.set('StartAvailability', e.newValues.StartAvailability);
e.record.set('EndAvailability', e.newValues.EndAvailability);
App.mcmAddIndividaulFlight({
focusmarketRecord: e.record,
successCallback: function(obj) {
e.record.data = obj;
App.mcmFindIndividualFlights(this.mcmSearchType, obj.Origin, obj.Destination,
obj.StartAvailability, obj.EndAvailability, obj.FlightNumber);
this.mcmHasChanges = true;
},
successScope: this,
failureCallback: App.mcmTabReload,
failureScope: App
});
}
}
}
}
var addFocusMarket = function(focusmarket) {
this.mcmRowEditing.cancelEdit();
var searchval = Ext.getCmp('searchGroup').getValue();
console.log("add focus market" + focusmarket);
if(searchval.search_type == "CityPair"){
var record = new Sch.model.Resource({
Id: 0,
Origin: focusmarket ? focusmarket.Origin : '',
Destination: focusmarket ? focusmarket.Destination: '',
CabinClass: focusmarket ? focusmarket.CabinClass: '',
StartAvailability: focusmarket ? focusmarket.startAvailability: '',
EndAvailability: focusmarket ? focusmarket.endAvailability: ''
});
console.log("records-->"+record);
}
else if(searchval.search_type == "IndividualFlights"){
var record = new Sch.model.Resource({
Id: 0,
Origin: focusmarket ? focusmarket.Origin : '',
Destination: focusmarket ? focusmarket.Destination: '',
FlightNumber: focusmarket ? focusmarket.FlightNumber: '',
CabinClass: focusmarket ? focusmarket.CabinClass: '',
StartAvailability: focusmarket ? focusmarket.startAvailability: '',
EndAvailability: focusmarket ? focusmarket.endAvailability: ''
});
console.log("records-->"+record);
}
App.mcmFocusMarketStore.insert(0, record);
this.mcmRowEditing.startEdit(0, 0);
this.mcmHasChanges = true;
};
当您创建ID时,请尝试使用唯一的ID。如果每次创建记录时都输入 0 作为 id,则网格中只会看到一条记录。每次使用 Ext.id() 或编写自己的 id 时,都需要生成一个唯一的 id。
var record = new Sch.model.Resource({//就在这里,这必须是唯一的//Id:0, 产地:焦点市场?焦点市场。原产地 : '', 目的地: 焦点市场 ?焦点市场。目的地: '', 舱位等级:焦点市场 ?焦点市场。舱位等级: ", 开始可用性: 焦点市场 ?focusmarket.startAvailability: '', 终端可用性: 焦点市场 ?focusmarket.endAvailability: '' });
相关文章:
- 如何将新的stateObject添加或附加到历史记录中
- btAdd click事件在添加记录后打开两个窗口
- 如何为动态生成的输入字段添加记录
- Jqgrid 使用 afterSubmit 事件获取新添加记录的 ID
- 使用Jquery向HTML表添加记录
- 剑道ui网格多次添加记录
- 我如何添加记录到一些JSON文件在angular js
- JavaScript的位置.没有添加记录到浏览器历史记录
- 为什么这段代码似乎没有向Meteor.users.profile对象添加记录?
- 在不刷新的情况下向数据库中添加记录
- Jquery + ajax.我的javascript函数有什么问题?删除记录,添加记录而不刷新
- 依赖剑道网格与动态过滤器防止添加记录
- 如何在使用AJAX点击保存时向表中添加记录
- 如何从extjs添加记录到数据库Java servlet
- 如何在不刷新页面的情况下在添加记录后刷新jTable
- 添加记录时出现ValidatorError错误
- jqgrid:动态添加记录后排序不起作用
- db.js - 向 IndexedDB 添加记录时出现问题
- 获取IndexedDB中添加记录的键
- Ajax添加记录与会话id和用户id问题