Hi,

I want to write a generic numeric sorting function that takes the
numeric column and sorts it.Here is my MXML code as of now :

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
height="100%" width="100%" layout="absolute" creationComplete="init
();" viewSourceURL="srcview/index.html" xmlns:local="*" >
<mx:Script source="CogIntegrator.as"/>
<mx:Script>
        <![CDATA[
private function sortNumeric(obj1:Object, obj2:Object):int {
var value1:Number = (obj1.n_Count == '' || obj1.n_Count == null) ?
null : new Number(obj1.n_Count);
var value2:Number = (obj2.n_Count == '' || obj2.n_Count == null) ?
null : new Number(obj2.n_Count);
if (value1 < value2) {
return -1;
} else if (value1 > value2) {
return 1;
} else {
return 0;
}
}
        ]]>
</mx:Script>
<mx:VBox height="100%" width="100%">
<mx:Button id="restoreButton" label="Restore" click="restoreHandler
(event);" height="3%"/>
<mx:AdvancedDataGrid height="95%" width="100%" id="pricingADG"
dataProvider ="{xmlData}"  >
<mx:columns>
        <mx:AdvancedDataGridColumn  dataField="c_Application"
headerText="Application" headerRenderer="MenuHeaderRenderer"/>
        <mx:AdvancedDataGridColumn  dataField="c_Department"
headerText="Department" headerRenderer="MenuHeaderRenderer"/>
        <mx:AdvancedDataGridColumn  dataField="n_Count"
sortCompareFunction="sortNumeric" headerText="Count"
headerRenderer="MenuHeaderRenderer"/>
        <mx:AdvancedDataGridColumn  dataField="n_Quantity"
headerText="Quantity" />
</mx:columns>
</mx:AdvancedDataGrid>
</mx:VBox>
</mx:Application>

The sortNumeric function works fine but it is not generic.Using the
above approach i have to define a different sorting function for
Quantity column also(have to use obj1.n_Quantity..).Is there a way to
somehow get the context of the column so that a generic sortNumeric
function can be used to sort all the numeric columns ,rather than me
writing a separate sorting function for all the columns?

Any guidance would be highly appreciated.

Thanks,
Shishir.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to