Hi,
I have a datagrid. I add a row to the datagrid using an ADD button. Once I add, I sort the datagrid based on a column. I also provide the serial numbers i.e. row numbers as first column to the datagrid. But, the serial number function does not apply after sorting. Hence, a new row added for e.g. row 5, based on sorting should be row 1, the serial number displayed is still row 5. The UI looks bad as numbers are not in correct order. the code is :
// Sorting Function : private function sortGrid():void { sortGridColl = new ArrayCollection(sortGridArray); sortA = new Sort(); sortByLevel = new SortField("Type", true, false); sortA.fields=[sortByLevel]; sortGridColl.sort=sortA; sortGridColl.refresh(); sortGrid.dataProvider=sortGridColl; sortGrid.rowCount=myDPColl.length +1; } // Serial Number function : private function sortGridSerialNumbers(oItem:Object,iCol:int):String { myDPColl = new ArrayCollection(sortGridArray); var iIndex:int = myDPColl.getItemIndex(oItem) + 1; return String(iIndex); } // Adding new row to datagrid : sortGrid.dataProvider.addItem ( { Type : typeName.text } );