Different editable properties on different items in a column in a datagrid

Different editable properties on different items in a column in a datagrid

Post by nikos10 » Sat, 27 Sep 2008 00:41:35


Is it possible to have different editable properties on different items in a column in a datagrid?
 
 
 

Different editable properties on different items in a column in a datagrid

Post by ANewFlexUs » Sat, 27 Sep 2008 03:57:35

I don't know what exactly you mean by 'different editable properties' but I
have dealt with this probelm recently on some of the dataGrids at work; we have
some extremely large classes containing 20+ properties, and a dataGrid will
only have, for example, 3 columns.

The best solution I have come up with is to create a second class with
placeholder variables for each column, and then assign the appropriate
properties to teh placeholder variables. In this way, you end up with 6+ rows
representing one class.

This also requires some additional bookkeeping on the programmer's part; one
would think that setting up an 'itemEditEnd' event to dump the text back to the
source variable would do the trick, but that drops the last character. My
solution was to set a text editor up to dump every keystroke into a storage
variable, and then dump the storage variable back to the appropriate element in
the original class when finished editing a cell.

It's a bit involved, and a lot of bookkeeping, but that's the only method I
know of to place different properties inside the same column of a DataGrid.

 
 
 

Different editable properties on different items in a column in a datagrid

Post by nikos10 » Sat, 27 Sep 2008 04:36:01

different editable properties, what I mean by this


basically each item in the dataprovider(assigned to the datagrid) has a
variable called user rank. If the user rank was greater than 4 for example, let
the user edit the text for that specific row and corresponding column.
 
 
 

Different editable properties on different items in a column in a datagrid

Post by ANewFlexUs » Sat, 27 Sep 2008 05:18:10

Then you should be able to do something like the attached example.

Basically, you check to see if the object that you clicked on has a rank <4;
if it does, then you preventDefault, which prevents the cell from being edited.

You might be able to check dataGrid.selectedItem.rank, rather than
dataProvider.getItemAt(event.RowIndex) as well.

Example:

public function editHandler(event:DataGridEvent):void {
if(dataprovider.getItemAt(event.rowIndex)) < 4 {
event.preventDefault();
}
}

<mx:DataGrid: itemEditBeginning="editHandler(event)"/>
 
 
 

Different editable properties on different items in a column in a datagrid

Post by nikos10 » Sat, 27 Sep 2008 06:19:54

What is dispatching the event you refer to and what type of DataGridEvent would it be?
 
 
 

Different editable properties on different items in a column in a datagrid

Post by ANewFlexUs » Sat, 27 Sep 2008 22:02:28

The event is dispatched whenever you try and edit the dataGrid, and the event type is DataGridEvent. It is dispatched by the dataGrid in the attached example.