Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex: Delete item from collection bound to datagrid and update the grid selected index
    primarykey
    data
    text
    <p>I have a datagrid with an xmlListCollection bound to it:</p> <pre><code>&lt;mx:DataGrid id="dgCompetente" includeIn="Competente" x="10" y="66" width="547" height="468" change="dgCompetente_changeHandler(event)" dataProvider="{colCompetente}" editable="false"&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn headerText="ID Competenţă" dataField="idCompetenta"/&gt; &lt;mx:DataGridColumn headerText="Denumire Competenţă" dataField="denCompetenta"/&gt; &lt;mx:DataGridColumn headerText="Competenţă Superioară" dataField="idCompSuperioara" labelFunction="labelFunctionCompetentaSuperioara"/&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; </code></pre> <p>and a button to delete the currently selected item in the datagrid, which has this function assigned to the click event:</p> <pre><code>&lt;s:Button id="btnDeleteCompetenta" includeIn="Competente" x="813" y="65" label="Stergere" click="deleteCompetenta()"/&gt; private function deleteCompetenta():void { try { var position:int = dgCompetente.selectedIndex; if (position &gt;= 0) { colCompetente.removeItemAt(position); dgCompetente.selectedIndex = position; } clearEdit(fieldsCompetente); saveCompetente(); } catch (error:Error) { errorHandler.defaultErrorHandler(error); } } </code></pre> <p>I want the selectedIndex to remain the same. So, if I delete item 2, the next in the list should be selected. The problem is that if I delete item 2, item 3 will be selected and I have no idea why.</p> <p>Can someone tell me what I'm missing?</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload