RE: [flexcoders] Dynamically poplulating an editable DataGrid

2005-05-10 Thread Tim Blair
Jim,

 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.
...
 I forgot to address the editing / not showing up issue.
 Try using undefined instead of empty string.

Ah, excellent!  Thanks, I knew there had to be something I was missing
:)

Tim.

--
---
Badpen Tech - CF and web-tech: http://tech.badpen.com/
---
RAWNET LTD - independent digital media agency
We are big, we are funny and we are clever!
 New site launched at http://www.rawnet.com/
---
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
---


 
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/
 




RE: [flexcoders] Dynamically poplulating an editable DataGrid

2005-05-09 Thread Tim Blair
Matt,

 Clearly it seems like a bug so I'd file it at 
 http://www.macromedia.com/go/wish

Cheers, will do.

 But there should be a simpler workaround I'd hope.
 What about calling invalidate() on the DataGrid?

I tried that, but nothing doing unfortunately :o\

Tim.

--
---
Badpen Tech - CF and web-tech: http://tech.badpen.com/
---
RAWNET LTD - independent digital media agency
We are big, we are funny and we are clever!
 New site launched at http://www.rawnet.com/
---
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
--- 

 




From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Matt Chotin
Sent: 09 May 2005 04:07
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Dynamically poplulating an editable
DataGrid



Clearly it seems like a bug so I'd file it at
http://www.macromedia.com/go/wish.  But there should be a simpler
workaround I'd hope.  What about calling invalidate() on the DataGrid?

 



From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Tim Blair
Sent: Sunday, May 08, 2005 6:28 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Dynamically poplulating an editable
DataGrid

 

Matt/Manish,

Matt wrote:
 When you add a new object to the dataProvider any chance you
 can add it with empty fields for the columns that do exist?
 I'd imagine that it not having any values whatsoever could
 cause something like this.

Manish wrote:
 I don't know why this might be happening, but I found that
 setting the initial value to   (single space) instead of 
 (blank string) fixes the issue.  Does that work for you?

Even when setting the value of the cells in each new row to
something
other than  I still couldn't edit the cells without first
creating a
new column.  Additionally, the value of the cells wasn't
displayed until
after the new row had been added.

In the end I had to do two things to get it to work, the first
of which
is a temendous hack that I really don't like.  Because I
couldn't edit
cell information until after a new columnn had been created,
when adding
a new row I forced creation and then immediate deletion of a new
column:

// new row added to the patta provider in the lines above
myDataGrid.addColumn(new DataGridColumn(temp));
myDataGrid.removeColumnAt(myDataGrid.columnCount-1);

Additionally, as Manish suggested, I had to give the initial
value of
each cell a non-empty string value (a single space) or even
after
editing the field, the label wouldn't be shown until after a new
row is
created.

As I said, hacky and not nice, but at least I have it working
they way I
expected it should!  So the question is -- what's going on here?
Bug?

Tim.

--
---
Badpen Tech - CF and web-tech: http://tech.badpen.com/
---
RAWNET LTD - independent digital media agency
We are big, we are funny and we are clever!
 New site launched at http://www.rawnet.com/
---
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited

Re: [flexcoders] Dynamically poplulating an editable DataGrid

2005-05-09 Thread Jim Laing
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/
 




Re: [flexcoders] Dynamically poplulating an editable DataGrid

2005-05-09 Thread Jim Laing
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/
 




RE: [flexcoders] Dynamically poplulating an editable DataGrid

2005-05-08 Thread Tim Blair
Matt/Manish,

Matt wrote:
 When you add a new object to the dataProvider any chance you
 can add it with empty fields for the columns that do exist?
 I'd imagine that it not having any values whatsoever could
 cause something like this.

Manish wrote:
 I don't know why this might be happening, but I found that
 setting the initial value to   (single space) instead of 
 (blank string) fixes the issue.  Does that work for you?

Even when setting the value of the cells in each new row to something
other than  I still couldn't edit the cells without first creating a
new column.  Additionally, the value of the cells wasn't displayed until
after the new row had been added.

In the end I had to do two things to get it to work, the first of which
is a temendous hack that I really don't like.  Because I couldn't edit
cell information until after a new columnn had been created, when adding
a new row I forced creation and then immediate deletion of a new column:

// new row added to the patta provider in the lines above
myDataGrid.addColumn(new DataGridColumn(temp));
myDataGrid.removeColumnAt(myDataGrid.columnCount-1);

Additionally, as Manish suggested, I had to give the initial value of
each cell a non-empty string value (a single space) or even after
editing the field, the label wouldn't be shown until after a new row is
created.

As I said, hacky and not nice, but at least I have it working they way I
expected it should!  So the question is -- what's going on here?  Bug?

Tim.

--
---
Badpen Tech - CF and web-tech: http://tech.badpen.com/
---
RAWNET LTD - independent digital media agency
We are big, we are funny and we are clever!
 New site launched at http://www.rawnet.com/
---
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
---


 
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/
 




RE: [flexcoders] Dynamically poplulating an editable DataGrid

2005-05-08 Thread Matt Chotin










Clearly it seems like a bug so Id
file it at http://www.macromedia.com/go/wish.
But there should be a simpler workaround Id hope. What about calling
invalidate() on the DataGrid?











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Tim Blair
Sent: Sunday, May 08, 2005 6:28 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders]
Dynamically poplulating an editable DataGrid





Matt/Manish,

Matt wrote:
 When you add a new object to the dataProvider
any chance you
 can add it with empty fields for the columns
that do exist?
 I'd imagine that it not having any values
whatsoever could
 cause something like this.

Manish wrote:
 I don't know why this might be happening, but
I found that
 setting the initial value to  
(single space) instead of 
 (blank string) fixes the issue. Does
that work for you?

Even when setting the value of the cells in each
new row to something
other than  I still couldn't edit the
cells without first creating a
new column. Additionally, the value of the
cells wasn't displayed until
after the new row had been added.

In the end I had to do two things to get it to
work, the first of which
is a temendous hack that I really don't
like. Because I couldn't edit
cell information until after a new columnn had
been created, when adding
a new row I forced creation and then immediate
deletion of a new column:

// new row added to the patta provider
in the lines above
myDataGrid.addColumn(new
DataGridColumn(temp));
myDataGrid.removeColumnAt(myDataGrid.columnCount-1);

Additionally, as Manish suggested, I had to give
the initial value of
each cell a non-empty string value (a single
space) or even after
editing the field, the label wouldn't be shown
until after a new row is
created.

As I said, hacky and not nice, but at least I have
it working they way I
expected it should! So the question is --
what's going on here? Bug?

Tim.

--
---
Badpen Tech - CF and web-tech: http://tech.badpen.com/
---
 RAWNET LTD - independent
digital media agency
 We are big, we are funny
and we are clever!
 New site launched at http://www.rawnet.com/
---
This message may contain information which is
legally
privileged and/or confidential. If you are
not the
intended recipient, you are hereby notified that
any
unauthorised disclosure, copying, distribution or
use
of this information is strictly prohibited. Such
notification notwithstanding, any comments,
opinions,
information or conclusions expressed in this
message
are those of the originator, not of rawnet
limited,
unless otherwise explicitly and independently
indicated
by an authorised representative of rawnet limited.
---












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 the Yahoo! Terms of Service.












Re: [flexcoders] Dynamically poplulating an editable DataGrid

2005-05-07 Thread Manish Jethani
On 5/7/05, Tim Blair [EMAIL PROTECTED] wrote:

 Additionally, after editing a cell, it appears that sometimes the
 underlying data model is updated but the display is not updated.  For
 example, using the code below, if I edit the one and only cell that's
 automatically created and the move the focus somewhere else, the new
 value isn't displayed (although I can get it back by re-editing the
 cell).

I don't know why this might be happening, but I found that setting the
initial value to   (single space) instead of  (blank string) fixes
the issue.  Does that work for you?


 
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/
 




RE: [flexcoders] Dynamically poplulating an editable DataGrid

2005-05-07 Thread Matt Chotin










When you add a new object to the
dataProvider any chance you can add it with empty fields for the columns that
do exist? Id imagine that it not having any values whatsoever could
cause something like this.











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Tim Blair
Sent: Saturday, May 07, 2005 10:22
AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Dynamically
poplulating an editable DataGrid





Evening all,

I'm having some issues with an editable data
grid. Basically it starts
of as an empty grid and the user can populate it
by adding columns and
rows, but it doesn't appear to be working as I
expect it to.

I can add columns using dg.addColumn() absolutely
fine, and they are
displayed as expected. However, when I add a
new row (by adding a new
Object to the dataProvier array), I can't actually
edit the field until
I've added another column. Once I've done this,
the new row can be
edited normally. I can also
force the row to be editable by tabbing
from one (already editable) row to a newly created
one.

Additionally, after editing a cell, it appears
that sometimes the
underlying data model is updated but the display
is not updated. For
example, using the code below, if I edit the one
and only cell that's
automatically created and the move the focus
somewhere else, the new
value isn't displayed (although I can get it back
by re-editing the
cell).

Can anyone shed some light on this situation, or
recommend another way
of going about things?

Thanks,

Tim.

PS. The code I'm testing with is as below:

?xml version=1.0
encoding=utf-8?
mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml

 mx:Script
 ![CDATA[
 //
import the grid classes so we can use them
 import
mx.controls.gridclasses.*;

 // the
dataprovider to use for the grid
 var
gripDP = [{col0:}];

 // adds
a new column to the data grid

function gridAddColumn(colName:String) {

// create a new column and give it an arbitrary name

var newCol:DataGridColumn = new
DataGridColumn(col+(myDataGrid.columnCount));

// set some stuff

newCol.headerText = colName;

newCol.editable = true;

newCol.sortable = false;

// add the column

myDataGrid.addColumn(newCol);

myDataGrid.spaceColumnsEqually();
 }

 // 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);
 }
 ]]
 /mx:Script

 !-- holder for the grid and
controls --
 mx:VBox
width=500 height=300
 !--
the actual data grid --

mx:DataGrid id=myDataGrid dataProvider={gripDP}
editable=true width=100%
height=240

!-- by default there's already one row, which is the row
titles --

mx:columns

mx:Array

mx:DataGridColumn editable=true sortable=false
headerText=- columnName=col0
/

/mx:Array

/mx:columns

/mx:DataGrid
 
 !--
the buttons for controlling the datagrid --

mx:HBox verticalAlign=bottom width=100%

mx:HBox width=100%

mx:Label text=Col:
/

mx:TextInput id=newColName width=80
change=btnNewCol.enabled =
newColName.text.length ? true : false /

mx:Button id=btnNewCol enabled=false
label=Add
Column click=gridAddColumn(newColName.text);
newColName.text = '' /

/mx:HBox

mx:Button label=Add Row click=gridAddRow() /

/mx:HBox
 /mx:VBox

/mx:Application


--
---
Badpen Tech - CF and web-tech: http://tech.badpen.com/
---
 RAWNET LTD - independent
digital media agency
 We are big, we are funny
and we are clever!
 New site launched at http://www.rawnet.com/
---
This message may contain information which is
legally
privileged and/or confidential. If you are
not the
intended recipient, you are hereby notified that
any
unauthorised disclosure, copying, distribution or
use
of this information is strictly prohibited. Such
notification notwithstanding, any comments,
opinions,
information or conclusions expressed in this
message
are those of the originator, not of rawnet
limited,
unless otherwise explicitly and independently
indicated
by an authorised representative of rawnet limited.
---












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 the Yahoo! Terms of Service.