Columns in DataTable may be "randomly" deleted. This happens in updateSchema(), because both the column update loop and the row update loop use the same variable "i". Since variable scope in JS is by function and not block, the column loop variable gets overwritten.

Repeat-by:
1. New Content->Basic->DataTable
2. data
3. Edit Schema
4. col1, add Column
5. col2, add Column
6. col3, Save
7. Edit Schema

Note that col2 is missing.

Fix:
Change the name of the variable in the row loop.
This commit is contained in:
ampli 2011-06-29 02:56:41 +03:00
parent 97ec859653
commit ed0c400440

View file

@ -618,9 +618,9 @@ WebGUI.Form.DataTable
// If the key has changed, update the row data
if ( col && col.key != newKey ) {
var rows = this.dataTable.getRecordSet().getRecords();
for ( var i = 0; i < rows.length; i++ ) {
rows[ i ].setData( newKey, rows[ i ].getData( oldKey ) );
rows[ i ].setData( oldKey, undefined );
for ( var r = 0; r < rows.length; r++ ) {
rows[ r ].setData( newKey, rows[ r ].getData( oldKey ) );
rows[ r ].setData( oldKey, undefined );
}
}