2013-06-24 4 views
1

고급 DataGrid가 있습니다.버튼 클릭시 고급 DataGrid 지우기?

[Bindable] 
     private var sales:ArrayCollection = new ArrayCollection([ 
      {Billno:"1", customerName:"vs", 
       phoneno:"1223456789", productName:"aaer",serialNo: "ajerf", saleDate:" 12/5/2013", quantity:1, priceperitem:12,total: 12}, 
      {Billno:"2", customerName:"vs1", 
       phoneno:1223456789, productName:"aaer",serialNo: "ajerf", saleDate: " 12/5/2013", quantity:1, priceperitem:12,total: 12}, 
      {Billno:"3", customerName:"vs", 
       phoneno:1223456789, productName:"aaer",serialNo: "ajerf", saleDate: " 12/5/2013", quantity:1, priceperitem:12,total: 12}, 
      {Billno:"4", customerName:"vs1", 
       phoneno:1223456789, productName:"aaer",serialNo: "ajerf", saleDate: " 12/5/2013", quantity:1, priceperitem:12,total: 12}, 
      {Billno:"5", customerName:"vs2", 
       phoneno:1223456789, productName:"aaer",serialNo: "ajerf", saleDate: " 12/5/2013", quantity:1, priceperitem:12,total: 12}, 
      {Billno:"6", customerName:"vs2", 
       phoneno:1223456789, productName:"aaer",serialNo: "ajerf", saleDate: " 12/5/2013", quantity:1, priceperitem:12,total: 12} 

     ]); 

public function resetForm() :* 
     { 

      sales=new ArrayCollection(); 

     } 

내 고급 데이터 그리드는 다음과 같습니다 : 내가 판매 = 새 ArrayCollection에 사용 클릭 버튼의 고급 데이터 그리드 값을 지울하지만 내 코드가 작동하지 않는 것은

<mx:AdvancedDataGrid id="myADG1" width="100%" height="100%" 
        initialize="gc.refresh();" variableRowHeight="true">   
    <mx:dataProvider> 
     <mx:GroupingCollection2 id="gc" source="{sales}"> 
      <mx:grouping> 
      <mx:Grouping label="Billno"> 
       <mx:GroupingField name="customerName"/> 

      </mx:Grouping> 
      </mx:grouping> 
     </mx:GroupingCollection2> 
    </mx:dataProvider>   

    <mx:columns> 
     <mx:AdvancedDataGridColumn width="125" dataField="customerName" headerText="customer"/> 

</fx : 구성 요소> </mx : itemRenderer> ->

</mx:columns> 
</mx:AdvancedDataGrid> 

답변

0

이 시도 :

public function resetForm():void { 
     myADG1.removeAll(); 
     //sales = new ArrayCollection();//this should be null if you dont need the Grid anymore 
     sales = null; 
} 


편집 :
당신은 그리드를 재사용하는 경우, 최선이 소스를 무효화 할 수 있습니다.

.invalidateList();

public function resetForm():void { 
     sales = new ArrayCollection(); 
     myADG1.invalidateList(); 
    } 
+0

아니요. 그리드와 작동하지 않습니다. – user2083041

+0

'dataGrid.dataProvider.removeALL();을'myADG1.dataProvider.removeAll();'로 변경 했습니까? – M4tchB0X3r

+0

업데이트 답변, 난 당신이 dataprovider – M4tchB0X3r