2010-11-23 78 views
0

我想在某人點擊位於刪除列下方的那一行的按鈕部分時刪除我的數據網格的一行。我想這些的許多不同的方式一個人要通過單擊刪除列中該行的按鈕部分刪除Datagrid的行?

<mx:DataGrid id="userGrid" dataProvider="{userGridData}" width="800" height="500" itemClick="userGrid_itemClickHandler(event)" creationComplete="userGrid_creationCompleteHandler(event)"> 
     <mx:columns> 
      <mx:DataGridColumn headerText="ID" dataField="user_id" /> 

      <mx:DataGridColumn headerText="Email" dataField="user_email"/> 

      <mx:DataGridColumn headerText="Delete" itemRenderer="ev.renderers.UserGridDelete" id="deleteCol"/> 
      <mx:DataGridColumn headerText="Edit" itemRenderer="ev.renderers.UserGridEditRender"/> 

     </mx:columns> 
    </mx:DataGrid> 

項渲染ev.renderers.UserGridEditRender有click事件的刪除按鈕房源就基本做userGridData.removeItemAt(userGrid.selectedIndex); (UserGridData =數據網格的供應商ID爲「userGrid」 ) 但每當我點擊按鈕的例外是拋出

RangeError: Index '-1' specified is out of bounds. 

回答

1

如何讓你的項目渲染器按鈕,調度已在其選定的「數據」的事件。

dispatchEvent(new DataMonkeyEvent(DataMonkeyEvent.DELETE_ROW, this.data)); //where "this" is the button and the event should bubble. 

監聽外文檔中的事件,並相應地修改您的userGridData ... invalidateList()如果你不使用內部擴展的dataProvider是聽孩子們改變了搖擺。

希望有所幫助。 --jeremy

+0

我已經嘗試過這一點,有趣的是,只有索引爲0和1的行纔會引發異常,因爲它的工作原理很好。 – 2010-11-23 18:58:07

相關問題