一、获取选择行
可以通过以下属性进行选择项的获取
this.dataGrid.selectedIndex
this.dataGrid.selectedIndices
this.dataGrid.selectedItem
this.dataGrid.selectedItems
二、程序设置选择行
对于单行的选择可以通过下面进行选择
this.dataGrid.selectedIndex=iIndex;
this.dataGrid.selectedItem=item;
对于多选项则不能直接通过
this.dataGrid.selectedIndices.push(iIndex);
this.dataGrid.selectedItems.push(item);
这样做行不能选中
应该通过定义Indices或Items数组,并直接设置才可以实现多选。
如下:
var selectedIndices:Array=new Array();
for(var i:int=0;i<this._currentPageData.length;i++)
{
if(this._dataProviderSelection.contains(this._currentPageData[i]))
{
selectedIndices.push(i);
}
}
this.dataGrid.selectedIndices=selectedIndices;
注意:通过程序设置选择,不会触发itemClick事件。