How to get dragged items into grid?
<mx:DataGrid id="dg1" dataProvider="{cNumbersList}" cornerRadius="3"
allowMultiple开发者_如何转开发Selection="true"
change="selectedItem=(event.target as DataGrid).selectedItem.contactName;
selectedSno=(event.target as DataGrid).selectedItem.contactNo;"
dropEnabled="true" dragMoveEnabled="true" dragEnabled="true"
fontWeight="normal">
<mx:columns>
<mx:DataGridColumn dataField="contactName" headerText="Name"/>
<mx:DataGridColumn dataField="contactNo"
headerText="ContactNo"/>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid id="dg2" cornerRadius="3" allowMultipleSelection="true"
visible="false" dataProvider="{}" dropEnabled="true"
dragMoveEnabled="true" dragEnabled="true" fontWeight="normal">
<mx:columns>
<mx:DataGridColumn dataField="contactName" headerText="Name"/>
<mx:DataGridColumn dataField="contactNo"
headerText="ContactNo"/>
</mx:columns>
</mx:DataGrid>
How can I get all dragged items in to second grid(dg2)?
If you are looking to access the items dropped into dg2
from dg1
, here is how to do that:
var list:ListCollectionView = dg2.dataProvider;
for(i = 0; i < list.length; i++)
trace(list.getItemAt(i));
Btw, something tells me that this is wrong:
change="selectedItem=(event.target as DataGrid).selectedItem.contactName;
selectedSno=(event.target as DataGrid).selectedItem.contactNo;"
What are you trying to accomplish with it?
<mx:HBox>
<mx:List id="List1" dataProvider="{grpList}" labelField="groupName" dragMoveEnabled="true" dragEnabled="true" allowMultipleSelection="true" dropEnabled="true" width="120" />
<mx:VBox>
<mx:Label text="Selected Groups :" width="122" color="#C90855"/>
<mx:List id="List2" dropEnabled="true" labelField="groupName" dragEnabled="true" dragMoveEnabled="true" allowMultipleSelection="true" dataProvider="{selectedGroupsListArray}" width="120" height="111" borderColor="#0A8AE4"/>
</mx:VBox>
</mx:HBox>
<mx:HBox>
<mx:DataGrid id="dg" dataProvider="{cNumbersList}" cornerRadius="3" allowMultipleSelection="true"
change="selectedItem=(event.target as DataGrid).selectedItem.contactName;selectedSno=(event.target as DataGrid).selectedItem.contactNo;"
dropEnabled="true" dragMoveEnabled="true" dragEnabled="true" fontWeight="normal" height="163">
<mx:columns>
<mx:DataGridColumn dataField="contactName" headerText="Name"/>
<mx:DataGridColumn dataField="contactNo" headerText="ContactNo"/>
</mx:columns>
</mx:DataGrid>
<mx:VBox>
<mx:Label text="Selected Contacts :" width="122" color="#C90855" height="16"/>
<mx:DataGrid id="selectedContsList" cornerRadius="3" allowMultipleSelection="true"
dropEnabled="true" dragMoveEnabled="true" dragEnabled="true" fontWeight="bold" borderColor="#066EB7" height="144">
<mx:columns>
<mx:DataGridColumn dataField="contactName" headerText="Name"/>
<mx:DataGridColumn dataField="contactNo" headerText="ContactNo"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:HBox>
精彩评论