Created
February 24, 2010 03:44
-
-
Save perlDreamer/313076 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/www/extras/yui-webgui/build/form/datatable.js b/www/extras/yui-webgui/build/form/datatable.js | |
index 3f9d1d2..514fe74 100644 | |
--- a/www/extras/yui-webgui/build/form/datatable.js | |
+++ b/www/extras/yui-webgui/build/form/datatable.js | |
@@ -49,7 +49,7 @@ WebGUI.Form.DataTable | |
data = {}; | |
var columns = this.dataTable.getColumnSet().getDefinitions(); | |
for ( var i = 0; i < columns.length; i++ ) { | |
- data[ columns[ i ].key ] = ""; | |
+ data[ columns[ i ].key ] = columns[i].formatter == "date" ? new Date : ""; | |
} | |
} | |
this.dataTable.addRow( data ); | |
@@ -626,18 +626,11 @@ WebGUI.Form.DataTable | |
key : newKey, | |
formatter : format, | |
resizeable : ( col ? col.resizeable : 1 ), | |
- sortable : ( col ? col.sortable : 1 ) | |
+ sortable : ( col ? col.sortable : 1 ), | |
+ editor : ( format == "date" ? "date" : "textbox") | |
}; | |
var newIndex = col ? col.getKeyIndex() : undefined; | |
- // Set the editor | |
- if ( format == "date" ) { | |
- newCol.editor = "date"; | |
- } | |
- else { | |
- newCol.editor = "textbox"; | |
- } | |
- | |
this.dataTable.insertColumn( newCol, newIndex ); | |
if ( col ) { | |
// Get a new reference so we remove the right column | |
@@ -650,6 +643,18 @@ WebGUI.Form.DataTable | |
} | |
this.dataTable.removeColumn( delCol ); | |
} | |
+ else { | |
+ //Set data in the new column to useful defaults. | |
+ var allRecords = this.dataTable.getRecordSet().getRecords(); | |
+ var numRecords = allRecords.length; | |
+ for (j=0; j < numRecords; j++) { | |
+ if (format == "date") { | |
+ allRecords[j].setData(newKey, new Date); | |
+ } else { | |
+ allRecords[j].setData(newKey, ''); | |
+ } | |
+ } | |
+ } | |
i++; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment