Flex editable datagrid with itemEditor "combobox" not auto scroll when I edit a cell
I have a flex datagrid with dynamic columns (matrix 60 x 60 by sample) and each cell is a "combobox". My problem is when the vertical scroll position moves through any row following. How can I control this erro开发者_StackOverflow中文版r? How can I use "verticalScrollPosition"????
<mx:DataGrid height="100%" id="dgLineRanges" editable="{editable}" itemEditBegin="modifyEditedData(event);" itemEditEnd="saveEditedData(event);" horizontalScrollPolicy="auto" visible="false"/>
I use this code:
// Handle the itemEditBegin event.
private function modifyEditedData(event:DataGridEvent):void
{
// Handle the event here.
event.preventDefault();
// El triangulo inferior no es editable
if(event.columnIndex > 0 && event.columnIndex > event.rowIndex)
{
//Buscar el rango que corresponde y actualizar su valor
selectedCell = dgLineRanges.dataProvider.getItemAt(event.rowIndex).getItemAt(event.columnIndex);
// Creates an item editor.
dgLineRanges.createItemEditor(event.columnIndex,event.rowIndex);
// All item editors must implement the IDropInListItemRenderer interface
// and the listData property.
// Initialize the listData property of the editor.
IDropInListItemRenderer(dgLineRanges.itemEditorInstance).listData =
IDropInListItemRenderer(dgLineRanges.editedItemRenderer).listData;
// Copy the cell value to the TextInput control.
dgLineRanges.itemEditorInstance.data = dgLineRanges.editedItemRenderer.data;
// Copy the cell value to the RangeComboItemEditor control.
var rangeCombo:RangeComboItemEditor = dgLineRanges.itemEditorInstance as RangeComboItemEditor;
// Sólo permitimos editar si está prohibido (pero puede permitirlo)
rangeCombo.editable = !selectedCell.forbidden;
// Esta variable se tiene en cuenta a la hora de habilitar o no los botomes de prohibido
enableForbidden(true);
// Establecer el foco
model.setRangeComboIEFocus(rangeCombo, !selectedCell.forbidden);
}
else
{
enableForbidden(false);
}
}
private function saveEditedData(event:DataGridEvent):void
{
// Check the reason for the event.
if (event.reason == DataGridEventReason.CANCELLED || event.columnIndex == 0)
{
// Do not update cell.
return;
}
// Guardamos indices de cela para facilitar posible tratamiento de botones
// prohibido / permitodo
lastRowIndex = event.rowIndex;
lastColumnIndex = event.columnIndex;
//Buscar el rango que corresponde
var stopsRange:FareOriginDestDTO = dgLineRanges.dataProvider.getItemAt(event.rowIndex).getItemAt(event.columnIndex);
if(stopsRange.saveAction == IfsConst.SAVE_ACTION_NONE)
stopsRange.saveAction = IfsConst.SAVE_ACTION_UPDATE;
// Get the new data value from the editor.
var newRangeCode:int= event.currentTarget.itemEditorInstance.code;
//Actualizar su valor
stopsRange.rangeCode = newRangeCode;
//Actualizar "Forbidden"
if (newRangeCode == -1)
stopsRange.forbidden = true;
else
stopsRange.forbidden = false;
// Simétrico (si no está en la diagonal)
if( event.rowIndex != event.columnIndex-1 )
{
stopsRange = dgLineRanges.dataProvider.getItemAt(event.columnIndex-1).getItemAt(event.rowIndex+1);
// Solo se cambia la celda simétrica si:
// Celda principal es "Forbidden" y la simétrica también
// Celda principal no es "Forbidden"
if ((newRangeCode == -1 && stopsRange.rangeCode == -1) || newRangeCode != -1)
{
if (stopsRange.saveAction == IfsConst.SAVE_ACTION_NONE)
stopsRange.saveAction = IfsConst.SAVE_ACTION_UPDATE;
stopsRange.rangeCode = newRangeCode;
}
}
// Close the cell editor.
dgLineRanges.destroyItemEditor();
// Notify the list control to update its display.
dgLineRanges.dataProvider.itemUpdated(event.itemRenderer.data);
// Mandatory dataProvider refresh
dgLineRanges.dataProvider.refresh();
// Disable copying data back to the control.
//event.preventDefault();
}
精彩评论