gpt4 book ai didi

actionscript-3 - 向下或向上滚动数据网格到选定的索引行 Flex

转载 作者:行者123 更新时间:2023-12-03 01:12:53 24 4
gpt4 key购买 nike

我正在数据网格中的其中一列上执行查找操作。找到包含该项目的行后,我将其作为选定的索引行,突出显示它。但现在我还想向下或向上滚动数据网格(如果该项目超出屏幕范围)以在此查找操作中自动显示所选项目。

谢谢。

最佳答案

您尝试过 scrolltoindex() 方法吗?看看Anuj Gakhar's article关于将 scrolltoindex() 与数据网格一起使用。

以下是文章中的示例:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
initialize="doInit();" creationComplete="setSelectedItem()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

// this holds the grid data
[Bindable]
private var myData:ArrayCollection = new ArrayCollection();
// change this name here to change the selected item on load
[Bindable]
private var initialFName:String = "Joe9";

private function doInit():void
{
myData.addItem({fname:"Joe",lname:"Bloggs"});
myData.addItem({fname:"Joe1",lname:"Bloggs"});
myData.addItem({fname:"Joe2",lname:"Bloggs"});
myData.addItem({fname:"Joe3",lname:"Bloggs"});
myData.addItem({fname:"Joe4",lname:"Bloggs"});
myData.addItem({fname:"Joe5",lname:"Bloggs"});
myData.addItem({fname:"Joe6",lname:"Bloggs"});
myData.addItem({fname:"Joe7",lname:"Bloggs"});
myData.addItem({fname:"Joe8",lname:"Bloggs"});
myData.addItem({fname:"Joe9",lname:"Bloggs"});
}

private function setSelectedItem():void
{
var gData:Object = dGrid.dataProvider;
for(var i:Number=0; i < gData.length; i++)
{
var thisObj:Object = gData.getItemAt(i);
if(thisObj.fname == initialFName)
{
dGrid.selectedIndex = i;
//sometimes scrollToIndex doesnt work if validateNow() not done
dGrid.validateNow();
dGrid.scrollToIndex(i);
}
}
}
]]>
</mx:Script>

<mx:DataGrid id="dGrid" dataProvider="{myData}" visible="true">
<mx:columns>
<mx:DataGridColumn dataField="fname" headerText="FirstName" />
<mx:DataGridColumn dataField="lname" headerText="LastName" />
</mx:columns>
</mx:DataGrid>

</mx:Application>

关于actionscript-3 - 向下或向上滚动数据网格到选定的索引行 Flex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6612210/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com