Adam Parkin
Adam Parkin

Reputation: 18660

Flex mx.controls.DataGrid with conditionally editable cells

I have a mx.controls.DataGrid datagrid on a page, and the requirement I have is that some cells on that datagrid be editable dependent upon some condition in the state of the system.

So far as I can tell I can set the entire datagrid to be editable via the editable property, or all values in a column via the DataGridColumn's editable property, but I don't see a way to set this on the level of an individual cell within the datagrid.

Any suggestions?

Upvotes: 0

Views: 385

Answers (2)

helloflash
helloflash

Reputation: 2457

This works great:

// cell at the intersection of row 1 and column 2

dg.addEventListener(ListEvent.ITEM_CLICK, cellEditable);

function cellEditable(e:ListEvent):void {
   e.target.editable = (e.rowIndex == 1 && e.columnIndex === 2) ? true : false;
}

Upvotes: 1

Crabar
Crabar

Reputation: 1857

A good example you can find here (Preventing a cell from being edited). It solves your problem completely. Just change the condition in the example to your own.

Upvotes: 1

Related Questions