[小技巧] 通过监听DataGrid的ListEvent.Change控制button是否可用.

如下, 在没有点击[默认]是, 后两个button的enable=false;

image

点击一个之后:

image

简单实现方法:

_dataGridStudent.addEventListener(ListEvent.CHANGE, onSlectedChange);

对应监听函数:

		_actionEdit.enabled = _dataGridStudent.selectedItem != null;
		_actionDelete.enabled = _dataGridStudent.selectedItem != null;

这样实现了:
1.无点击时不可用
2.点击且有选择时可用
3. 如点击之后, 按住Ctrl点击, 可取消对其选择, 这时将置按钮于不可用状态.

This entry was posted in ActionScript, Flex and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>