From ed0c400440eb9abcd1ca24f85177459eba0189d5 Mon Sep 17 00:00:00 2001 From: ampli Date: Wed, 29 Jun 2011 02:56:41 +0300 Subject: [PATCH] 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. --- www/extras/yui-webgui/build/form/datatable.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/extras/yui-webgui/build/form/datatable.js b/www/extras/yui-webgui/build/form/datatable.js index d9f89b854..651c5f1ce 100644 --- a/www/extras/yui-webgui/build/form/datatable.js +++ b/www/extras/yui-webgui/build/form/datatable.js @@ -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 ); } }