Labelfunction in a datagrid

maybe someone can help me out with this... i am able to get a labelfunction to work fine (it sums the totals of the dataprovider) like so:
in my datagridcolumn with id = "grid1" i have labelFunction="sumFunction"
my sumFunction looks like this:
        public function sumFunction(col:DataGridColumn):String
            var n:int = grid1.dataProvider.length;
            var sum:Number = 0;
            for (var i:int = 0; i < n; i++)
                sum += grid1.dataProvider[i][col.dataField];
            return parentApplication.currencyFormatter.format(sum);//.toFixed(2);
but i find i need to create a sumFunction for every datagrid with a different ID and i'm going to have many. i want to be able to reuse code (best practice) and reuse the same function for all grids. the problem is i dont know which grid to loop over the dataprovider for and return the result to. so i started doing something like this:
        public function sumFunction(dgName:String,col:DataGridColumn):String
            var n:int = this[dgName]dataProvider.length;
            var sum:Number = 0;
            for (var i:int = 0; i < n; i++)
                sum += int(this[dgName]dataProvider[i][col.dataField]);
            return parentApplication.currencyFormatter.format(sum);
but then my labelfunction needs another argument/parameter passed to it. oddly enough why doesn't the labelFunction work without passing in the col:DataGridColumn in the first example but now it doesnt once i add another argument/parameter to the function?
i was expecting this to then work if i changed the labelfunction on each datagrid to pass the id of the datagrid to let the sumFunction know which one to use:
labelFunction="sumFunction('grid2')"
this throws an error that i need another argument/parameter but i dont know what to pass in. i'm also getting errors about a string... anyone know how i can accomplish this?

but i'm not within that packaged AS file... i'm in an MXML file that uses it like this:
    <local:FooterDataGrid id="ptqGrid" x="10" y="487" width="940" itemClick="itemClickEvent('ptqGrid',event);" dataProvider="{parentApplication.Service.perfToQuota.lastResult}" rowCount="5">
        <local:columns>
            <local:FooterDataGridColumn headerText="Quota Description" width="180" dataField="quota_desc">
                <mx:DataGridColumn headerText="Totals:" width="180" textAlign="right"/>
            </local:FooterDataGridColumn>
            <local:FooterDataGridColumn headerText="Quota" dataField="quota" labelFunction="{parentApplication.price_labelFunc}" textAlign="right" >
                <mx:DataGridColumn labelFunction="sumFunction" dataField="quota" textAlign="right" />
            </local:FooterDataGridColumn>
            <local:FooterDataGridColumn headerText="Total Revenue" labelFunction="{parentApplication.price_labelFunc}" textAlign="right" dataField="tot_rev">
                <local:itemRenderer>
                <mx:Component>
                <mx:Label text="{parentApplication.currencyFormatter.format(data.tot_rev)}" textAlign="right" color="#0000FF"
                styleName="lblNoUnderline" buttonMode="true" useHandCursor="true"
                mouseOver="styleName='lblUnderline';" mouseChildren="false"
                mouseOut="styleName='lblNoUnderline';"/>
                </mx:Component>
                </local:itemRenderer>
                <mx:DataGridColumn labelFunction="sumFunction" dataField="tot_rev" textAlign="right" />
            </local:FooterDataGridColumn>
            <local:FooterDataGridColumn headerText="Target Earnings" textAlign="right" labelFunction="{parentApplication.price_labelFunc}" dataField="trgt_earn">
                <mx:DataGridColumn labelFunction="sumFunction" dataField="trgt_earn" textAlign="right" />                   
            </local:FooterDataGridColumn>
            <local:FooterDataGridColumn headerText="Total Earnings" textAlign="right" labelFunction="{parentApplication.price_labelFunc}" dataField="tot_earn">
                <local:itemRenderer>
                <mx:Component>
                <mx:Label text="{parentApplication.currencyFormatter.format(data.tot_earn)}" textAlign="right" color="#0000FF"
                styleName="lblNoUnderline" buttonMode="true" useHandCursor="true"
                mouseOver="styleName='lblUnderline';" mouseChildren="false"
                mouseOut="styleName='lblNoUnderline';"/>
                </mx:Component>
                </local:itemRenderer>   
                <mx:DataGridColumn labelFunction="sumFunction" dataField="tot_earn" textAlign="right" />
            </local:FooterDataGridColumn>
            <local:FooterDataGridColumn headerText="Achievement" textAlign="right" dataField="ach">
                <mx:DataGridColumn labelFunction="averageFunction" dataField="ach" textAlign="right" />                   
            </local:FooterDataGridColumn>
        </local:columns>
    </local:FooterDataGrid>
and here is my sumFunction that is giving me the problem and does not have access to the owner property:
        public function sumFunction(col:FooterDataGridColumn):String
            var n:int = ptqGrid.dataProvider.length;
            var sum:Number = 0;
            for (var i:int = 0; i < n; i++)
                sum += int(ptqGrid.dataProvider[i][col.dataField]);
            return parentApplication.currencyFormatter.format(sum);//.toFixed(2);

Similar Messages

  • LabelFunction for cell datagrid validation

      private function price(item:Object, column:DataGridColumn):String {
                 if (item.col1.length !=9) { return item.col1 + "error" };
                 if (item.col2.length > 15){ return item.col2 + "error"};
                 if (item.col2.length > 10){ return item.col3 ,setStyle("color", 0xff0000) + "error" };
    can someone please help me out with this function im trying to validate the items on a datagrid for lenght of theirs string but when i try to do it this way i get really bad errors.
      <mx:DataGridColumn headerText="Vendor Number" dataField="col1" itemRenderer="PriceLabel" />
        <mx:DataGridColumn headerText="Invoice Number" dataField="col2" itemRenderer="PriceLabel"/>
        <mx:DataGridColumn headerText="Invoice Date" dataField="col3" />
    i like to validate each column separetely but its seems to try to do it all at once.
    Any help would be greatly appreciated.
    Thanks
    you

    Try using else if for the last two if statements.
    But you should probably check the column first, then do the formatting, using the column parameter.
    I'll  show you how if you don't know.

  • Datagrid labelfunction sort problem

    I have a problem with sorting on all columns the moment I
    implement a labelFunction in a datagrid. When I click the datagrid
    headers nothing happens anymore. I need the labelFunction in the
    first place to format some data.
    Does anyone has a solution for my problem?
    Here's the code (fragmented):
    <mx:DataGrid id="dgUsers" dataProvider="{aUsers}">
    <mx:columns>
    <mx:DataGridColumn headerText="number"
    labelFunction="dispUsers"/>
    <mx:DataGridColumn headerText="name"
    labelFunction="dispUsers"/>
    <mx:DataGridColumn headerText="role"
    labelFunction="dispUsers"/>
    </mx:columns>
    </mx:DataGrid>
    private function dispUsers(item:Object, column:
    DataGridColumn):String {
    switch(column.headerText) {
    case "number":
    return item.username;
    case "name":
    return formatName(item.voornaam, item.tussenvoegsel,
    item.achternaam);
    case "role":
    return item.roleName;
    default:
    return "";
    private function formatName(sVoor:String, sMidden:String,
    sAchter:String):String {
    var sName:String = "";
    if(sAchter != "") {
    sName += sAchter;
    if(sVoor != "") {
    if(sName != "") {
    sName += ", ";
    sName += sVoor;
    if(sMidden != "" && sVoor != "") {
    sName += " " + sMidden;
    return sName;

    Because you have a labelFunction, the DataGrid now needs a
    sortCompareFunction to tell it how to sort your data. Here is some
    extra info.
    http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=L iveDocs_Parts&file=00000598.html
    Joan Lafferty
    Flex SDK QA

  • Dynamic text in a dataGrid column?

    i have a datagrid. i want to populate the first column with a different label depending on the row number.
    A good example of this would be
    Column 1 label
    Label 1
    Label 2
    Label 3
    Label 4
    I have these labels in an array, so i could access them if i had the row number.
    Anyone know how to do this?
    thanks!

    Hi peteandrus,
    You can simply use the code snippet below to display the labels row wise....
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
       <mx:Script>
       <![CDATA[
        import mx.controls.Alert;
          [Bindable]private var myAC:Array = [
             {Column1:'Label 1', Column2:"Text 1"},
             {Column1:'Label 2', Column2:"Text 2"},
             {Column1:'Label 3', Column2:"Text 3"},
             {Column1:'Label 4', Column2:"Text 4"}
       ]]>
       </mx:Script>
    <mx:DataGrid id="dataGrid" dataProvider="{myAC}" x="10" y="177" visible="true">          
      <mx:columns>
       <mx:DataGridColumn  headerText="Column 1 label" dataField="Column1"/>           
       <mx:DataGridColumn dataField="Column2" headerText="Column 2 label" />           
      </mx:columns>
    </mx:DataGrid>
    </mx:Application>
    If you really want to find the row index based assignment you can try something using labelFunction for the DataGrid column...
    Something like below:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
       <mx:Script>
       <![CDATA[
        import mx.controls.dataGridClasses.DataGridColumn;
        import mx.controls.Alert;
        [Bindable]private var myAC:Array = [
      {Column1:'Label 1', Column2:"Text 1"},
            {Column1:'Label 2', Column2:"Text 2"},
            {Column1:'Label 3', Column2:"Text 3"},
            {Column1:'Label 4', Column2:"Text 4"}
    private var counter:int=-1;         
        private function column1LabelFunction(item:Object, coulmn:DataGridColumn):String
         var strLabel:String="";
         counter++;
         if(counter < myAC.length)
          strLabel = myAC[counter].Column1;
      return strLabel;    
       ]]>
       </mx:Script>
    <mx:DataGrid id="dataGrid" dataProvider="{myAC}" x="10" y="177" visible="true">          
      <mx:columns>
       <mx:DataGridColumn  headerText="Column 1 label" labelFunction="column1LabelFunction"/>           
       <mx:DataGridColumn dataField="Column2" headerText="Column 2 label" />           
      </mx:columns>
    </mx:DataGrid>
    </mx:Application>
    Thanks,
    Bhasker Chari

  • Data in XML vs. Modified with LabelFunction

    Hi,
    We have a datagrid that is being populated through an HTTPService call that generates an XML via PHP.
    We are wondering which of these two scenarios would be faster in terms of load/render times:
    a) Load all the data in the XML directly, hence increasing the size of the XML (simplified example below):
    <item status="Read"/>
    OR
    b) Load ID values in the XML, keeping XML file size down and placing a labelFunction on the DataGrid where Actionscript would set the values:
    <item status="1"/>
    private function dgFormatDate(item:Object, column:DataGridColumn):String
         if(column.dataField == "@status") {
              if(item[column.dataField] == "1"){
                   var status:String = "Read";
                   return status;
         return item[column.dataField];
    Thoughts?
    Thanks!

    I guess it comes doen to how much xml there is.  To be honest I'd for the first option (and have in the past)  and aviod the labelFunction logiv for each item.  This will increase your maintence time when you change or edit a node etc.
    Also I would imagine its quicker for the player to handle the xml, and render wise, not to have to run label function logic for each node.
    I think what you should realy be thinking about is more lazy loading.  How many xml records you realy need.  Ie work more towards showing a it of data, then when the user drills down, go back to the server to load more.
    Just my thoughts
    Andrew

  • How to use datagrid labelfunction to format currency

    So are I'm displaying item prices in a datagrid. I want to format the price to 2 decimal places and display a $. Here's the code i have so far. btw, it's not working. Please tell me what I'm missing.
    Here's my call to the labelfunc:
    <mx:DataGridColumn dataField="value" headerText="Price" labelFunction="price_labelFunc"/>
    Here's my formatter:
      <mx:CurrencyFormatter id="Price"
                precision="2"
                rounding="none"
                decimalSeparatorTo="."
                thousandsSeparatorTo=","
                useThousandsSeparator="true"
                useNegativeSign="true"
                currencySymbol="$"
                alignSymbol="left"/>
    Here's my labelfunc:
    public function price_labelFunc(item:Object, column:DataGridColumn):String
                return Price.format(item.value);
    The label for the price is being returned in an arraycollection at "value".
    ie. value= 567.13445666666
    Thanks in advance for your assistance.

    I've used your code, which seems to be ok. Here is the sample,
    <mx:DataGrid id="dg" dataProvider="{_acItem}">
         <mx:columns>
              <mx:Array>
                   <mx:DataGridColumn headerText="Item" dataField="item"  />
                   <mx:DataGridColumn headerText="Price" dataField="price" labelFunction="formatPrice" />
              </mx:Array>
         </mx:columns>
    </mx:DataGrid>
    <mx:CurrencyFormatter id="cfPrice"
                precision="2"
                rounding="none"
                decimalSeparatorTo="."
                thousandsSeparatorTo=","
                useThousandsSeparator="true"
                useNegativeSign="true"
                currencySymbol="$"
                alignSymbol="left"/>
    [Bindable]private var _acItem:ArrayCollection
    public function init():void {
         var item: Object;
         _acItem = new ArrayCollection();
         item = {item:"PC", price:"1000.99"};
         _acItem.addItem(item);
         item = {item:"Laptop", price:"567.13545666666"};
         _acItem.addItem(item);
    private function formatPrice(value: Object, column: DataGridColumn): String {
         return cfPrice.format(value.price);

  • Editable Datagrid with LabelFunction Problems

    Hi,
    I'm having problems with a datagrid with editable columns and labelFunctions.
    The problem is that when i leave the editable field by a way that wasnt with Escape Key, the datagrid apply again the labelFunction and destroy the number formattion adding a lot of numbers.
    When the field is filled with 0000,00 he just adds more zeros, like 0.000.000,0000 and keep going after do the same process.
    And when the field has a number different of zero, he apply the labelFunction then after he remove the labelFunction. After few times it just make the number vanish and the cell goes empty.
    I read the documentation about editing cell and tryed to implement a solution to prevent the cell be edited, without sucess.
    The source code goes attached for some advice on my problem.
    Thanks, Fredy.

    Hi,
    I solved a part of problem with some changes that i've made.
    Now there is no problem with values different of zero, when i got just number, its fine, but still have problems with zero values.
    The snippet code goes next, the bold part that was modified from the last sample.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
         layout="vertical"
         backgroundColor="white">
         <mx:Script>
              <![CDATA[
                   import mx.controls.Alert;
                   import mx.events.DataGridEventReason;
                   import mx.controls.TextInput;
                   import mx.controls.dataGridClasses.DataGridColumn;
                   import mx.formatters.NumberFormatter;
                   import mx.events.DataGridEvent;
                   import mx.collections.ArrayCollection;
                   [Bindable] private var collection:ArrayCollection = new ArrayCollection([
                        {code:1, description:"Item 1", value:4564654},
                        {code:2, description:"Item 2", value:00000000},
                        {code:3, description:"Item 3", value:00000000},
                        {code:4, description:"Item 4", value:00000000},
                        {code:5, description:"Item 5", value:00000000},
                        {code:6, description:"Item 6", value:00000000},
                        {code:7, description:"Item 7", value:00000000}
                   private var formatter:NumberFormatter;
                   private function formatterFunction(item:Object, column:DataGridColumn):String {
                      if (formatter == null){
                           formatter = new NumberFormatter();
                           formatter.decimalSeparatorTo = ",";
                           formatter.thousandsSeparatorTo = ".";
                           formatter.decimalSeparatorFrom  = ",";
                           formatter.thousandsSeparatorFrom = ".";
                           formatter.useThousandsSeparator = true;
                           formatter.precision = 4;
                      return formatter.format(item[column.dataField]);
                 private function editEndHandler(event:DataGridEvent):void {
                    var myEditor:TextInput = TextInput(event.currentTarget.itemEditorInstance);
                    var newVal:Number = isNaN(Number(myEditor.text)) ? myEditor.text as Number : 0.0000;
                    var oldVal:Number = Number(event.currentTarget.editedItemRenderer.data[event.dataField]);
                     // it solves the partial part of the problem, but still have some errors
                     if (event.reason == DataGridEventReason.CANCELLED || event.reason == DataGridEventReason.OTHER) {
                        return;
                    if (oldVal == newVal ) {
                             // i've tryed this, but the itemEditor still open
                             event.preventDefault();
                             // if I just put 'return', still have the same problem
                             // return;
              ]]>
         </mx:Script>
         <mx:Label text="Bug datagrid editavel com labelFunction"
              fontSize="16"
              fontWeight="bold" />
         <mx:DataGrid dataProvider="{collection}"
              editable="true"
              itemEditEnd="editEndHandler(event)">
              <mx:columns>
                   <mx:DataGridColumn headerText="Código"
                        dataField="code"
                        editable="false"/>
                   <mx:DataGridColumn headerText="Descrição"
                        dataField="description"
                        editable="false"/>
                   <mx:DataGridColumn headerText="Valor"
                        width="300"
                        dataField="value"
                        labelFunction="formatterFunction"
                        editable="true"/>
              </mx:columns>
         </mx:DataGrid>
    </mx:Application>
    @Alex
    Thanks for the answer.
    I want to edit this column, but if there is no 'change' i dont want to apply again the label function and close the itemEditor.
    I've tryed to call event.preventDefault() but i dont know what to do next.
    Do you have some advice how to solve my problem?
    This is just happening when i got zero values on my datagrid =/
    Thanks all for the answers.

  • DataGrid and labelFunction

    Hi all!
    I have a DataGrid, and I have two columns where i want to manipulate the data shown. I tried using a labelfunction, but it turns out the labelfunction is called each time I focus out, and not only when the DataGrid is initialized.
    I've seen theres an initialize for DataGrid, but how can i use this to manipulate the data from my two columns?
    Sincerly

    How do you wrap an object?  It depends on how you are getting your data.  If
    you are using RemoteObject or can control the data type being sent over the
    wire, I would simply add a new getter to the data class.
    The most rudimentary way is something like this:  Say you had a ShoppingCart
    record:
    class ShoppingCartRecord
        public var catalogID:int;
    A wrapper class might look like:
    class DisplayableShoppingCartRecord
        public function DisplayableShoppingCartRecord(orig:ShoppingCartRecord)
            original = orig;
        public var original:ShippingCartRecord;
        public function get catalogID():int
            return original.catalogID;
        private var _displayName:String;
        public function get displayName():String
            if (!_displayName)
                _displayName = yourOldLabelFunction(orig);
            return _displayName;
    Then at some point, you loop through the original data set and instantiate
    the wrapped versions and pass that dataprovider to the datagrid.

  • Referencing custom filled column (labelFunction) in datagrid

    I got a column in a datagrid which is filled with data using some calculations done in a labelFunction.
    now i got a second column, which need the data of the previous mentioned column.
    normally you would type:  item.Data or something, but that does not work for the calculated field.
    how would i reference the first mentioned column in the labelFunction of the second?
    thnx

    The cheap way is to reference the the other column's labelFunction and call
    it again.  It means that the labelFunction will be called twice per row.
    You can get to the columns via DataGrid(owner).columns[]
    Another possibility is to add the labelFunction to the data objects or a
    subclass of the data objects.

  • When labelFunction for datagrid is called?

    I have a datagrid with three columns, and there is a
    labelFunction for one of the columns.
    I add a breakpoint in side of the labelFunction, I found that
    the labelFunction is called 4 times.
    when labelFunction for datagrid column is called? why there
    is so many calls of labelFunction
    PS:
    I set data provider for datagrid in creationComplete event of
    the datagrid, and the data provider just contains one item.

    labelFunction is called for every row/item, and for each
    column that has the labelFunction specified.
    Sometimes I have found the label function is called with a
    null item. I am in the habit of checking for null in all
    labelFunctions.
    Tracy

  • How to disaply multiple column of a table in a single flex datagrid column

    Hi,
    I have a table in my database which has say 3 column (Firstname,LastName,Location). I wanted to display these 3 different values in a single column in flex datagrid.
    Could you please help me out in this
    Thanks,
    Pratik

    Generally, in such scenarios each column is made corresponding to the column in database only and not single column.
    However, we can setStyle of a datagrid to make it appear as if all three  columns have been populated in single.
    set verticalGridLines="false" for dataGrid. Further cosmetic changes can be made to realise the required look.
    In some cases, labelFunction of a datagridColumn also suffices the need.
    Tanu

  • How do I pass a value from a selected datagrid row to a popup

    I am working on a project tracking application in flex and need to pass the value of one of the rows from the datagrid to a popup. We have a screen with 2 data grids. The first datagrid lists the projects, their start, and end date and the project owner. The datagrid below the first datagrid lists the tasks for that specific project listed in the datagrid above. When you click on the project name above, the datagrid below is populated with the tasks. Within the tasks datagrid are start and end date boxes.
    What I need to do is be able to pass the project ID from the original datagrid into a popup that is called when a user changes the date of a project task. The popup is designed to submit a reason for why the user is changing the date on the task. In short, when they submit a reason, I need the project id passed from the datagrid into the popup so when submit is clicked, the proper row in the DB table is update via a CFC. Thank you.

    I tried that, but when I try to build the project, I get the error that there is a call to an undefined value. Here is code:
    Project Component:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
        width="100%" height="100%" creationComplete="init();" xmlns:mxml="components.mxml.*">
        <mx:Script>
            <![CDATA[
                import mx.events.ListEvent;
                import mx.controls.dataGridClasses.DataGridColumn;
                import mx.rpc.events.ResultEvent;
                import mx.managers.PopUpManager;
                import mx.core.IFlexDisplayObject;
                import components.mxml.NewProject;
                import components.mxml.NewTask;
                import components.mxml.dateChangeNotice;
                import mx.controls.Alert;
                private function init():void{
                    roGetData.getProjects();
                    //roGetData.getTasks();
                private function projectClick(event:ListEvent):void{
                    //Alert.show(dgProjects.selectedItem.projectID);
                    roGetData.getTasks(dgProjects.selectedItem.projectID);
                private function refreshProjects(event:MouseEvent):void{
                    roGetData.getProjects();
                private function ResultEvent_Projects(event:ResultEvent):void{
                    dgProjects.dataProvider = event.result;
                private function ResultEvent_Tasks(event:ResultEvent):void{
                    adgTasks.dataProvider = event.result;
                private function ResultEvent_UpdateTasks(event:ResultEvent):void{
                    Alert.show('Your task was updated');
                private function showNewProject():void{
                    var newProjectWindow:IFlexDisplayObject =
                        PopUpManager.createPopUp(this, NewProject, true);
                    newProjectWindow.addEventListener(MouseEvent.CLICK, refreshProjects);
                private function showNewTask():void{
                    var newTaskWindow:IFlexDisplayObject =
                        PopUpManager.createPopUp(this, NewTask, true);
                private function dateFormat(item:Object, column:DataGridColumn):String{
                    return dateFormatter.format(item[column.dataField]);
                    //Function calls the Reason popup window
                //private function changeReason():void{
                    //Create Popup Window
                    //var resultWindow:IFlexDisplayObject =
                    //PopUpManager.createPopUp(this, dateChangeNotice, false);
            ]]>
        </mx:Script>
        <mx:RemoteObject id="roGetData" destination="ColdFusion" source="projectTracker.components.cfc.controllers.getController">
            <mx:method name="getProjects" result="ResultEvent_Projects(event);" fault="Alert.show(event.fault.faultString);" />
            <mx:method name="getTasks" result="ResultEvent_Tasks(event);" fault="Alert.show(event.fault.faultString);" />
        </mx:RemoteObject>
        <!--<mx:RemoteObject id="roUpdateData" destination="ColdFusion" source="projectTracker.components.cfc.controllers.updateController">
            <mx:method name="updateTasks" result="ResultEvent_UpdateTasks(event);" fault="Alert.show(event.fault.faultString);" />
        </mx:RemoteObject>-->
        <mx:DateFormatter id="dateFormatter" />
        <mx:HBox width="100%">
            <mx:Label text="Projects:" />
            <mx:Button label="Insert New Project" click="showNewProject();"/>
        </mx:HBox>   
        <mx:Panel width="100%" height="45%" title="Projects">
            <mx:DataGrid id="dgProjects" width="100%" height="100%" itemClick="projectClick(event);" dataProvider="">
                <mx:columns>
                   <mx:DataGridColumn dataField="projectID" headerText="ProjectID" visible="false" />- I Need to pass this value
                    <mx:DataGridColumn dataField="name" headerText="Project" />
                    <mx:DataGridColumn dataField="startDate" headerText="Date Started" labelFunction="dateFormat" />
                    <mx:DataGridColumn dataField="endDate" headerText="Completion Date" labelFunction="dateFormat" />
                    <mx:DataGridColumn dataField="description" headerText="Description" />
                    <mx:DataGridColumn dataField="statusName" headerText="Status" />
                    <mx:DataGridColumn dataField="ownerName" headerText="Owner" />
                </mx:columns>
            </mx:DataGrid>
        </mx:Panel>
        <mx:Panel width="100%" height="45%" title="Project Tasks">
            <mx:AdvancedDataGrid id="adgTasks" width="95%" height="100%" variableRowHeight="true">
                <mx:columns>
                    <mx:AdvancedDataGridColumn dataField="taskID" visible="false" width="50" />
                    <mx:AdvancedDataGridColumn dataField="name" width="25" />
                    <!--<mx:AdvancedDataGridColumn dataField="startDate" headerText="Date Started" />
                    <mx:AdvancedDataGridColumn dataField="endDate" headerText="Completion Date" />-->
                    <mx:AdvancedDataGridColumn id="descript" dataField="description" headerText="Description" width="50"/>
                    <mx:AdvancedDataGridColumn dataField="ownerID" headerText="Owner" width="25"  />
                    <mx:AdvancedDataGridColumn dataField="notes" headerText="Project Notes" width="50"/>
                    <mx:AdvancedDataGridColumn dataField="Dates" headerText="Dates" width="50"/>
                </mx:columns>
                <mx:rendererProviders>
                    <mx:AdvancedDataGridRendererProvider dataField="taskID" columnIndex="5">
                        <mx:renderer>
                            <mx:Component>
                                <mxml:dgDateHSlider startDate="{data.startDate}" endDate="{data.endDate}"/>   
                            </mx:Component>
                        </mx:renderer>
                    </mx:AdvancedDataGridRendererProvider>
                </mx:rendererProviders>
            </mx:AdvancedDataGrid>   
        </mx:Panel>
        <mx:HBox width="100%">
            <mx:Label text="Tasks:" />
            <mx:Button label="Insert New Task" click="showNewTask();"/>
            <mx:Spacer width="200"/>
        </mx:HBox>
    </mx:VBox>
    Popup Components
    <?xml version="1.0" encoding="utf-8"?>
    <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="400" title="Reason for Date Change" backgroundColor="#E5E4E4">
    <mx:Script>
        <![CDATA[
                 import mx.events.ValidationResultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.managers.PopUpManager;
                import mx.core.IFlexDisplayObject;
                import components.mxml.NewUser;
                import mx.controls.Alert;
                import components.mxml.Projects;
                import components.mxml.NewTask;
            //Clear Text Area Function
           public function Clear():void{
                reasonText.text = "";
            //function to send notes to db via RO
            public function writeNotes():void{
      into here-->    updateReason.reasonUpdate(taskID.selectedItem,reasonText.text);  taskID.selectedItem is not recognized. It errors on compile
            //remote object Results Event
            public function reasonResult(event:ResultEvent):void{
                Alert.show("Label update successful, thank you!");
                Clear();
        ]]>
    </mx:Script>
    <!--Update Remote Object-->
    <mx:RemoteObject id="updateReason" destination="ColdFusion" source="projectTracker.components.cfc.controllers.createController">
        <mx:method name="reasonUpdate" result="reasonResult(event);" fault="Alert.show(event.fault.faultString);"/>
    </mx:RemoteObject>
    <!--Reason Text Area-->
        <mx:TextArea x="19" y="60" width="90%" height="246" maxChars="1000" wordWrap="true" enabled="true" id="reasonText"/>
        <mx:Button label="Update" click="writeNotes()" right="65" bottom="0"/>
        <mx:Button label="Exit" click="PopUpManager.removePopUp(this);" right="10" bottom="0"/>
        <mx:Text text="Please Specify your reason for changing the dates of this task." width="90%" fontWeight="bold" top="10" horizontalCenter="0"/>
    </mx:TitleWindow>

  • Direction Needed: Storing calculated values from datagrid column in order to call values into graph

    Hi all,
    I am new to Flex/Flash Builder, actionscript, and mxml, so please be kind.
    I have developed a small program that has a component that displays a datagrid fed with information out of a mysql db via a php data services connection. Within that same component (page), I have a graph that charts the dates via a plot chart. I am interested in adding a line series to the graph, but the data I want to use is a calculated field in the datagrid which I used a custom lable function to derive and display. Can someone steer me to the correct method to store such values and how to call them into a chart?
    Some addition information
    Custom label function:
      /* Custom label function for the Delta1 column. Calculates the number of days between the planting date and 10% flower. */
                                  private function calculateTo1stFlower(item:Object, column:GridColumn):String {
                                            var tempDate1:Date = new Date(item.dflower10 - item.dplanting);
                                            return Math.round((tempDate1.time / MS_PER_DAY) + 1).toString();
    /* Number of milliseconds in a day. (1000 milliseconds per second * 60 seconds per minute * 60 minutes per hour * 24 hours per day) */
                                  private const MS_PER_DAY:uint = 1000 * 60 * 60 * 24;
    Within my spark datagrid
    <s:GridColumn width="30" headerText="Δ1" labelFunction="calculateTo1stFlower" ></s:GridColumn>
    I assume I need to store the array of values for this column and then chart the saved values as the xField within the LineSeries. Should I use a class based model?
    The following link seemed like it may be an appropriate path; I am not sure though.
    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7b51.html
    Thanks in advance for any support,
    Matthew

    Thanks for trying to post DDL, but you have no idea how to do a data model. You do not know that tables have to have keys, what ISO-11179 is, etc. 
    You have a table that is supposed to model companies. Your singular names says that there is only one company!  There is no company identifier (the industry standard is the DUNS). A customer is not a company. We do not use numeric data types for identifiers;
    do you do math on them? NO!  The attribute property comes after the attribute name (you never heard of ISO-11179). 
    Think about how silly VARCHAR(1) is. 
    CREATE TABLE Companies 
    (company_duns CHAR(9) NOT NULL PRIMARY KEY, 
     company_name VARCHAR(30)NOIT NULL, 
     margin_oil INTEGER NOT NULL, 
     margin_hangar INTEGER NOT NULL, 
     margin_cleaning INTEGER NOT NULL);
    INSERT INTO Companies
     VALUES (1, 'AviatKorea', 100, 125, 200), 
    (2, 'AXHollande', 50, 40, 30), 
    (3, 'BFXNorway', 60, 80, 600), 
    (4, 'EEEFrance', 10, 25, 60);
    CREATE TABLE Company_Tariffs
    (company_duns INTEGER NOT NULL
       REFERENCES Companies(company_duns), 
     tariff_type CHAR(1) NOT NULL
        CHECK (tariff_type IN ('A','B','C','D'),
     PRIMARY KEY (company_duns, tariff_type));
    INSERT INTO Company_Tariffs values (1, 'A'), (2, 'C'), (2, 'D'), (3, 'A'), (4, 'A'), (4, 'C'), (4, 'D')
    SELECT * -- do not use * in production code
      FROM Companies AS C,
           Company_Tariffs AS T 
     WHERE C.company_duns = T.company_duns;
    >> I would like something like with a computed column [ ] that retrieves the different contracts used: <<
    You might but a SQL programmer would not. This violated First Normal Form. It is a display report and is done in the presentation layers. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • What is the best way to create CRUD datagrids

    What is the best way to create CRUD datagrids that tell CF
    components to update sql tables. I find that I'm having to vreate
    all these columns with custom properites and its a bit of a chore:
    <mx:DataGridColumn id = "NatWest" dataField="NatWest"
    headerText="NatWest" editable="false"
    wordWrap="true"
    textAlign="right"
    headerStyleName="centered"
    labelFunction="price_labelFuncNatWest"
    sortCompareFunction="price_sortCompareFunc">
    I don't really want to use any wizards as I want control over
    my code.

    Hi Saythj,
    When mentioning "a database schema from XML", do you mean the
    XML Schema Collections? If that is what you mean, when trying to import XML files of the same schema type, you may take the below approach.
    Create an XML Schema Collection basing on your complex XML, you can find
    many generating tools online to do that.
    Create a Table with the above created schema typed XML column as below.
    CREATE TABLE youTable( Col1 int, Col2 xml (yourXMLSchemaCollection))
    Load your XML files and try to insert the xml content into the table above from C# or some other approaches. The XMLs that can't pass the validation fail inserting into that table.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Formatting a column in a datagrid

    If I want to format some data in a column of a datagrid is
    there a preferred way of doing that? I have used both an
    itemRenderer and a labelFunction
    Is there a preference to one or the other?

    lableFunction can be used when the tweaking required is very
    trivial and you want to modify some text getting displayed.
    (custom) itemRenderers can be used when we want to display
    something complex within a cell like few controls, icons, labels,
    links etc.

Maybe you are looking for

  • Sending a Rich Text (RTF) email using the Java Mail API

    Folks I've spent about half a day trying to find out how to do this, now I'm not even convinced you can. Here's the problem... I currently use JasperReports to generate an HTML report, this I then send as the body of a Multipart email. Because there

  • When is EXIT_SAPLMEREQ_002 triggered?

    Hi all xperts, I've seen on [this page|http://sapass.metro.client.jp/UserExit/MEREQ001.htm] many interesting userexits that in my system (46C) can't get to trigger. One of these is EXIT_SAPLMEREQ_002. I've seen that the INCLUDE contained, ZXM02U02, i

  • How can I shorten the video rendering time in PS CC2014?

    9 minute video just took 22 hours to render - 2.5 hours per video minute! 2 camera operation, all clips as Smart Objects and separated into 2 video groups, Camera Raw Filter edit for color control and sharpening, several clips have Transform cropping

  • Cannot unlock iPhone 4

    I have tried everything I can find on this forum and the web and I cannot unlock my iPhone 4.  I cannot get the "congratulations you iPhone is unlocked" in iTunes. I submitted the form to AT&T and got an email back saying they had granted my unlock r

  • How Best to Learn HTML DB

    I have developed with Oracle Forms for 8 years and wanted to learn this new development tool. I built the Issue Tracker tutorial. Now, I keep running into roadblocks when developing my own application. Can you offer any resources to get me a start?