Datagrid我有以下問題。我有一個更改客戶端的組合框,一旦選擇了一個客戶端,系統就會用一個帶有CheckBox和兩個RadioButton的ItemRenderer填充Datagrid。我第一次填充列表,一切正常。ItemRenderers保存更改後數據提供列表中的狀態
問題出在我更改客戶端並觸發事件以更改此類Datagrid的內容時。 Datagrid dataProvider被重新聲明爲一個新的ArrayCollection並迭代填充新的信息。
問題是雖然內容已更改,但複選框的狀態與更改之前保持一致。
這裏發生了什麼?我不明白。
EDIT:
private function showProductosTable(evt:ResultEvent, token:Object):void {
precioClienteModel.modelo.arrayPanelPrecioCliente = new ArrayCollection;
for each(var data:Object in evt.result as ArrayCollection) {
var pc:PanelPrecioClienteDatatype = new PanelPrecioClienteDatatype;
pc.ID = data.ID;
pc.clienteID = data.clienteID;
pc.productoID = data.productoID;
pc.producto = data.producto;
pc.proveedorID = data.proveedorID;
pc.proveedor = data.proveedor;
pc.productos_proveedorID = data.productos_proveedorID;
pc.cantidad_80 = data.cantidad_80;
pc.cantidad_100 = data.cantidad_100;
pc.kg_caja_80 = data.kg_caja_80;
pc.kg_caja_100 = data.kg_caja_100;
precioClienteModel.modelo.arrayPanelPrecioCliente.addItem(pc);
// Comprobamos si ya tenemos metido el ProductoID en nuestra Columna de Productos
if (!precioClienteModel.checkIfProductIDInList(pc.productoID)) {
precioClienteModel.modelo.arrayColumnaProductos.addItem({'productoID':pc.productoID, 'producto':pc.producto,
'proveedor1': {'value':0, 'selected':false},
'proveedor2': {'value':0, 'selected':false},
'proveedor3': {'value':0, 'selected':false},
'proveedor4': {'value':0, 'selected':false},
'proveedor5': {'value':0, 'selected':false},
'proveedor6': {'value':0, 'selected':false},
'proveedor7': {'value':0, 'selected':false},
'proveedor8': {'value':0, 'selected':false},
'proveedor9': {'value':0, 'selected':false},
'proveedor10': {'value':0, 'selected':false},
'proveedor11': {'value':0, 'selected':false},
'proveedor12': {'value':0, 'selected':false},
'proveedor13': {'value':0, 'selected':false},
'proveedor14': {'value':0, 'selected':false},
'proveedor15': {'value':0, 'selected':false}});
}
if (!precioClienteModel.checkIfProveedorIDInList(pc.proveedorID)) {
precioClienteModel.modelo.arrayFilaProveedores.addItem({'proveedorID':pc.proveedorID, 'proveedor':pc.proveedor});
}
}
}
和數據網格是:
<s:DataGrid id="preciosGrid" top="65" width="935" height="379" horizontalCenter="0" requestedRowCount="4"
dataProvider="{precioClienteModel.modelo.arrayColumnaProductos}">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="producto" headerText="Producto" width="150" editable="false"></s:GridColumn>
<s:GridColumn dataField="proveedor1" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor2" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor3" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor4" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor5" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor6" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor7" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor8" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor9" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor10" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor11" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor12" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor13" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor14" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
<s:GridColumn dataField="proveedor15" headerText="" width="52" editable="true" itemRenderer="renderers.PriceCellItemRenderer"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
和的itemRenderer:
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.listClasses.BaseListData;
import spark.components.DataGrid;
private var _listData:BaseListData;
[Bindable]private var isSelected:Boolean = false;
override public function prepare(hasBeenRecycled:Boolean):void {
}
protected function lblData_doubleClickHandler(event:MouseEvent):void {
isSelected = !isSelected;
data[column.dataField]['selected'] = isSelected;
}
override public function set data(value:Object) : void {
super.data = value;
if (value != null)
lblData.text = data[column.dataField]['value'];
}
[Bindable]public function get listData() : BaseListData {
return _listData;
}
public function set listData(value:BaseListData) : void {
_listData = value;
}
]]>
</fx:Script>
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="{isSelected?0xCDCDCD:0xFFFFFF}"/>
</s:fill>
</s:Rect>
<s:Label id="lblData" width="100%" height="100%"
textAlign="center" verticalAlign="middle"
doubleClickEnabled="true" doubleClick="lblData_doubleClickHandler(event)"/>
謝謝。
雅需要在這裏放一些代碼。沒有猜測'爲你。 – ethrbunny