Oh, sorry for the self reply, but I forgot to address the editing /
not showing up issue.
Try using undefined instead of empty string. The DataGrid replaces
undefined with single space (which can be a headache if you try and
cast to a number to return to your persistence layer ... don't get me
started ...). It's probably no different then just using a single
space, but I feel better about it on a purely emotional level :-)
The line is gridAddRow would then be:
for (var i = 0; i < aCols.length; i++) { newRow[aCols[i]] = undefined; }
Jim
On 5/9/05, Jim Laing <[EMAIL PROTECTED]> wrote:
> Sorry for such a late reply, but I'm pretty sure this isn't a bug.
>
> Your approach for adding a new row to the grid is slightly incorrect:
> you're pushing the new object onto the data provider of the grid.
> Instead, you should use the addItem method of the grid / dataProvider.
> Doing this causes the "modelChanged" event to be fired, which the
> DataGrid listens for internally and updates the grid accordingly.
> Adding and removing columns makes the grid recreates the rows (via the
> datagrid's initRows() function) while the modelChanged listener calls
> the drawRow() method of each row. So they both fix the issue, but as
> you said, the first is an ugly hack, and it might be slightly more
> expensive (creating versus redrawing).
>
> The code attached below seems to fix the issue (notice the last two
> lines). Let me know for sure if this works for you.
>
> Jim
>
> // adds a new row to the data grid
> function gridAddRow() {
> // we need to generate the object with the correct cells
> var newRow:Object = {};
> // get the current column names
> var aCols:Array = myDataGrid.columnNames;
> // loop through the column names and create an empty cell
> item for each
> for (var i = 0; i < aCols.length; i++) { newRow[aCols[i]] = ""; }
> // push the new row to the dataprovider
> // gripDP.push(newRow);
> myDataGrid.addItem(newRow);
> }
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/