代码之家  ›  专栏  ›  技术社区  ›  Mr Coder

是否通过单击删除列中该行的按钮部分删除数据报行?

  •  0
  • Mr Coder  · 技术社区  · 14 年前

    当有人单击位于删除列下面的行的按钮部分时,我想删除数据报的一行。我尝试了很多不同的方法其中之一

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

    项目render ev.renders.usergridEditrender有一个单击事件的删除按钮列表,它基本上是这样做的。 userGridData.removeItemAt(userGrid.selectedIndex); (usergrid data=ID为“usergrid”的网格的数据提供程序) 但是每当我点击这个按钮,就会抛出一个异常

    RangeError: Index '-1' specified is out of bounds.
    
    1 回复  |  直到 9 年前
        1
  •  1
  •   jeremy.mooer    14 年前

    让项目呈现器按钮分派包含选定“数据”的事件怎么样?

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

    在外部文档中侦听该事件并相应地编辑您的usergriddata…如果您不使用内部扩展数据提供程序来侦听子级已更改的jive,则invalidalList()。

    希望有帮助。--杰里米

    推荐文章