按钮点击清除高级数据网格?

时间:2013-06-24 07:45:10

标签: actionscript-3 flex4

我有一个高级数据网格。我想在按钮单击时清除高级数据网格值我使用sales = new ArrayCollection但它不起作用 我的代码是:

[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();

        }

我的高级数据网格是:

<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"/>

                                                                                                             &LT; / FX:成分&gt;                 &LT; / MX:的itemRenderer&GT; - &GT;                                                                              

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

1 个答案:

答案 0 :(得分:0)

试试这个:

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


修改
如果您正在重复使用Grid,最好使其源无效。

.invalidateList();

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