Flex 学习笔记 Datagrid中选中某行时光标定位
2012-06-28 11:29
375 查看
当Datagrid数据多时会出现滚动条,设置selectedIndex位置后,滚动条并不能根据Datagrid选中行的位置进行偏移。
这时候可使用verticalScrollPosition属性
AS:
protected function btn_clickHandler(event:MouseEvent):void
{
dgComplaints.selectedIndex=int(txt.text);
dgComplaints.verticalScrollPosition=dgComplaints.selectedIndex;
}
MXML:
<s:TextInput id="txt"/>
<s:Button label="定位" id="btn" click="btn_clickHandler(event)"/>
<mx:DataGrid id="dgComplaints" height="100">
<mx:dataProvider>
<s:ArrayList>
<fx:Object>
<fx:Artist>Pavement</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Slanted and Enchanted</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement1</fx:Artist>
<fx:Price>9.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement2</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement3</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Slanted and Enchanted</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement4</fx:Artist>
<fx:Price>9.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement5</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement6</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Slanted and Enchanted</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement7</fx:Artist>
<fx:Price>9.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement8</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
</s:ArrayList>
</mx:dataProvider>
<mx:columns>
<mx:DataGridColumn dataField="Artist" />
<mx:DataGridColumn dataField="Price" />
<mx:DataGridColumn dataField="Album" />
</mx:columns>
</mx:DataGrid>
这时候可使用verticalScrollPosition属性
AS:
protected function btn_clickHandler(event:MouseEvent):void
{
dgComplaints.selectedIndex=int(txt.text);
dgComplaints.verticalScrollPosition=dgComplaints.selectedIndex;
}
MXML:
<s:TextInput id="txt"/>
<s:Button label="定位" id="btn" click="btn_clickHandler(event)"/>
<mx:DataGrid id="dgComplaints" height="100">
<mx:dataProvider>
<s:ArrayList>
<fx:Object>
<fx:Artist>Pavement</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Slanted and Enchanted</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement1</fx:Artist>
<fx:Price>9.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement2</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement3</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Slanted and Enchanted</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement4</fx:Artist>
<fx:Price>9.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement5</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement6</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Slanted and Enchanted</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement7</fx:Artist>
<fx:Price>9.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
<fx:Object>
<fx:Artist>Pavement8</fx:Artist>
<fx:Price>11.99</fx:Price>
<fx:Album>Brighten the Corners</fx:Album>
</fx:Object>
</s:ArrayList>
</mx:dataProvider>
<mx:columns>
<mx:DataGridColumn dataField="Artist" />
<mx:DataGridColumn dataField="Price" />
<mx:DataGridColumn dataField="Album" />
</mx:columns>
</mx:DataGrid>
相关文章推荐
- 工作学习笔记——C#自定义类型剪贴板操作、自定义鼠标光标定位问题
- Flex学习笔记:DataGrid内容修改监听器——itemEditEnd
- Flex 学习笔记 Datagrid中创建自定义ComboBox控件及数字校验
- flex学习笔记 datagrid(一)
- FLEX学习笔记:屏蔽DataGrid中的dataTip
- flex学习笔记 datagrid(二)
- flex学习笔记之5 DataGrid
- Flex学习笔记(Day 1)
- GRID用法(取行、列值;定位选中某行等等)
- 强大的DataGrid组件[11]_主从(Master-Details)的实现——Silverlight学习笔记[19]
- 关于Axuer7.0高级交互设计学习笔记——如何制作复选框的全部选中效果
- DataGrid,DataList学习笔记
- Flex学习笔记
- flex 学习笔记 一个可以动态缩放的tree
- flex学习笔记2
- Flex权威指南3学习笔记之一------界面知识(二)
- 记录点学习的东西-flex.datagrid应用
- flex 学习笔记 ExternalInterface(二)
- CXGRID用法(取行、列值,定位选中某行等等)
- flex学习笔记 使用函数,显示实时更新的标签