ComboBox error: Ext={version:"2.2"};window["undefined"]=...
array is undefined
chrome://firebug/content/blank.gifExt={version:"2.2"};window["undefined"]=...new Date()).getTime()-this.getTime())};
The thing is that it does save the new value to the database correctly.
I've made some changes to the combo:
1. The field text is always shown (and not the value).
2. The user can write a new field text. This is being saved as a new row to database.
The ComboBox:
catCb = new Ext.form.ComboBox({
getValue: function(){
if(this.store.find('category', new RegExp('^' + this.getRawValue() + '$', 'i')) == -1) return this.getRawValue();
else return this.value;
},
allowBlank : true,
typeAhead : true,
lazyRender:true,
forceSelection: false,
triggerAction: 'all',
selectOnFocus: true,
listClass: 'x-combo-list-small',
store: catDs,
valueField: 'premisescategory_id',
displayField: 'category'
});
gridCm = new Ext.grid.ColumnModel([
{
header: "Fastighetskategori",
id: "columnCategory",
dataIndex: 'premisescategory_id',
editor: catCb,
renderer: function(value, meta, record) { return record.get('category'); }
}
]);
I noticed now that the error happens somewhere in my saveRows function:
var saveRows = function() {
alert(123);
var records = gridCmp.getStore().getModifiedRecords();
if(!records.length > 0) return;
var data = ;
Ext.each(records, function(record) {
record.data.id = record.id;
data.push(record.data);
});
Ext.Ajax.request({
url: '/premises/save',
params: {data: Ext.encode(data)},
failure: function() {
Ext.Msg.alert('Fel', 'Någonting gick snett!');
},
success: function(response, options) {
var respTxt = Ext.decode(response.responseText);
if(respTxt.success) {
gridCmp.getStore().commitChanges();
gridSm.clearSelections();
// Replace the new rows temporary id's with the new from db (key=old, value=new)
Ext.each(respTxt.regeneratedID, function(row) {
var dr = gridDs.getById(row.oldID);
dr.id = row.newID;
});
Ext.getCmp('gridBtnSave').disable();
Ext.getCmp('gridBtnUndo').disable();
Ext.MessageBox.show({
title: 'OK',
msg: 'Dina ändringar genomfördes',
buttons: Ext.MessageBox.OK,
animEl: 'gridBtnSave',
icon: Ext.MessageBox.INFO
});
}
else {
Ext.MessageBox.show({
title: 'Fel',
msg: 'Dina ändringar kunde inte genomföras!',
buttons: Ext.MessageBox.OK,
animEl: 'gridBtnSave',
icon: Ext.MessageBox.ERROR
});
}
}
})
};
update:
Found the solution:
I added following if:
if(respTxt.regeneratedID) {
// Replace the new rows temporary id's with the new from db
Ext.each(respTxt.regeneratedID, function(row) {
var dr = gridDs.getById(row.oldID);
dr.id = row.newID;
});
}
#If you have any other info about this subject , Please add it free.# |