Summary Row on adv. datagrid with no dataprovider

Hello,
Just new to Flex and still need to find out some things.
Created two advanced datagrids, the first WITH a dataprovider returning articles .. the second datagrid was added as a sort of Shopping cart and has no dataprovider.
I'm able to drag and drop articles from datagrid1 to datagrid2 (shopping cart), but I'm unable to show "Total price" at the bottom of the shopping cart.
Seems logical since it need data to make summary SUM field, but how can I tackle this best?
1. add empty dataprovider?
2. create an datacollection on the fly?
<mx:dataProvider>
      <mx:GroupingCollection id="gc" source="CREATE DATACOLLECTION FROM ACTUAL PRESENT DATA">
        <mx:Grouping>
           <mx:GroupingField name="Territory">
            <mx:summaries>
              <mx:SummaryRow summaryPlacement="group">
                <mx:fields>
                  <mx:SummaryField dataField="Price"
                    label="Total" operation="SUM"/>
                                  </mx:fields>
              </mx:SummaryRow>
            </mx:summaries>
          </mx:GroupingField>
        </mx:Grouping>
      </mx:GroupingCollection>
    </mx:dataProvider>
Please advice.
thanks a million
TomBr   

looks like it didn't understand correctly. Solution beneath is not adding a new row, but is only a solution for adding an extra column with some calculated value.
Am I correct that there is no default function for adding an extra row with the SUM of a column?
ok, added a datagrid since (as you mentioned) I'll need it anyway.
After adding a datagrid and creating a httpservice that can load data into the shopping cart, I'm still unable to add the SummaryRow with Totals
As soon as I remove the dataprovider="{getshopcartdataArray}" parameter from "<mx:AdvancedDatagrid" and add the extra <mx:dataProviderpart (with source pointing to correct DP) ... nothing works: loading data doens't work, drag/drop doens't work anymore and total row is not seen anyware
this is the datagrid and this is the page I used creating this: http://livedocs.adobe.com/flex/3/langref/mx/collections/SummaryRow.html
<mx:AdvancedDataGrid y="450" id="cart" initialize="gc.refresh();" designViewDataType="flat" height="250" left="10" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true" borderThickness="5" borderColor="#3F88BB" right="10">
   <mx:dataProvider>
      <mx:GroupingCollection id="gc" source="{getshopcartdataArray}">
        <mx:Grouping>
          <mx:GroupingField name="prijsexcl">
            <mx:summaries>
              <mx:SummaryRow summaryPlacement="group">
                <mx:fields>
                  <mx:SummaryField dataField="prijsexcl"
                    label="Total" operation="SUM"/>
                </mx:fields>
             </mx:SummaryRow>
           </mx:summaries>
         </mx:GroupingField>
       </mx:Grouping>
      </mx:GroupingCollection>
    </mx:dataProvider>
  <mx:columns>
        <mx:AdvancedDataGridColumn headerText="ID" dataField="cdartikel" width="30" editable="false"/>
        <mx:AdvancedDataGridColumn headerText="Zoeknaam" dataField="zoeknaam" width="40" editable="false" />
        <mx:AdvancedDataGridColumn headerText="Omschrijving" dataField="omschr" width="150" editable="false" />
        <mx:AdvancedDataGridColumn headerText="Prijs Incl" dataField="prijsincl" width="30" editable="false" />
        <mx:AdvancedDataGridColumn headerText="Prijs Excl" dataField="prijsexcl" width="30" editable="false" />
        <mx:AdvancedDataGridColumn headerText="Prijs per" dataField="prijsper" width="30" editable="false" />
        <mx:AdvancedDataGridColumn headerText="Eenheid" dataField="eenheid" width="30" editable="false" />
        <mx:AdvancedDataGridColumn headerText="Datum verschijning" dataField="verschijningsdatum" width="40" editable="false" />
        <mx:AdvancedDataGridColumn datafield="Total" />
  </mx:columns>
</mx:AdvancedDataGrid>

Similar Messages

  • Error while saving dynamic row values of datagrid with record.

    hi friends,
    i am trying to add dynamic row in datagrid and save that value with record.i succeeded in first part while i am saving the record the error show like this.
    errro:Property fromAmount not found on com.ci.view.Task and there is no default value.
    how i resolve this error.
    any suggession welcom
    thanks in advance.
    B.venkatesan
    code:
    package:
    package com.ci.view
        [Bindable]
        public class Task
            public function Task(frmAmount:String,toAmount:String,commissionPercentage:String)
                this.frmAmount=frmAmount;
                this.toAmount=toAmount;
                this.commissionPercentage=commissionPercentage;
            public var frmAmount:String;
            public var toAmount:String;
            public var commissionPercentage:String;
    main mxml:
    [Bindable]
                private var tasks:ArrayCollection;
                private static const ADD_TASK:String= "";
                private function init():void
                    tasks = new ArrayCollection();
                    tasks.addItem(new Task("0","1000","0"));
                    tasks.addItem({frmAmount:ADD_TASK});
                private function checkEdit(e:DataGridEvent):void
                    // Do not allow editing of Add Task row except for
                    // "Click to Add" column
                    if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
                        e.preventDefault();
                private function editEnd(e:DataGridEvent):void
                    // Adding a new task
                    if(e.rowIndex == tasks.length - 1)
                        var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                        var txtIn1:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                        var txtIn2:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                        var dt:Object = e.itemRenderer.data;
                        // Add new task
                        if((txtIn.text) != ADD_TASK)
                            var x:String=String(txtIn.text);
                            tasks.addItemAt(new Task("", "", ""), e.rowIndex);
                        // Destroy item editor
                        commPlanDetGrid.destroyItemEditor();
                        // Stop default behavior
                        e.preventDefault();

    Venktesan,
    You are trying compare String and int..! which is not possible try to case the txtIn.text to int using parseInt(txtIn.text).
    ORIGINAL:
    if(txtIn.text != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
                        tasks.addItemAt(new Task(txtIn.text, 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
    EDITED:
    if(parseInt(txtIn.text) != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
                        tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
    Thanks
    Pradeep

  • Adv datagrid with grouping

    i have
                <mx:AdvancedDataGrid id="ordersAdvGrid"
                                     width="100%" height="100%"
                                     resize="gridCollection.refresh();"
                                     initialize="gridCollection.refresh();"
                                     change="onOrderGridChange(event)"
                                     rollOver="FlexGlobals.topLevelApplication.showTip('Select an order or order status to view  the order pads.')"
                                     rollOut="FlexGlobals.topLevelApplication.destroyTip()">       
                    <mx:dataProvider>
                        <mx:GroupingCollection2 id="gridCollection" source="{model.orderHistory}">
                            <mx:grouping>
                                <mx:Grouping label="orderTemplateName">
                                    <mx:GroupingField name="orderStatusName"/>
                                </mx:Grouping>
                            </mx:grouping>
                        </mx:GroupingCollection2>
                    </mx:dataProvider>       
                    <mx:columns>
                        <mx:AdvancedDataGridColumn dataField="orderTemplateName" headerText="Orders" showDataTips="true"/>
                    </mx:columns>
                </mx:AdvancedDataGrid>
    Is there any way to expand one or more of the grouping , so after the refresh all the groups are collapsed, how can i expand them programmatically
    thanks

    Hi,
    Use displayItemsExpanded="true" or ordersAdvGrid.displayItemsExpanded="true"

  • Pre select datagrid with multiple colors

    how to pre select rows in a datagrid with multiple colors based on a condition?
    for eg: I have a status column.Based on the value of the status,the rows should be highlighted.
              if(status=='arrived'){
                   highlight in green;
              }else
               if(status=='delayed'){
                   highlight in red;

    try this, override drawRowBackground function
    public CustomDataGrid extends DataGrid
         override protected function drawRowBackground(s:Sprite,rowIndex:int,y:Number, height:Number, color:uint, dataIndex:int):void
              var item:Object = this.dataProvider.getItemAt(dataIndex);
              if (item.status == 'arrived')
                   color = 0x00FF00;
              else if (item.status == "delayed")
                   color = 0xFF0000;
              super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);

  • Need for a Datagrid with variableRowHeight="true" and custom Item Renderer to display exact rows

    Hi again, developers:
    I'm in a search of a datagrid  with certain characteristics:
         - variableRowHeight = "true"
         - only one column
         - each row must have a custom item renderer with possibly different heights, and a fixed width
         - the datagrid must show always every item in the data provider with no vertical scroll bars, what means that the datagrid height must have always the exact height sum of all the item renderers it is displaying.
         - and no extra empty rows must appear in the last positions of the datagrid
    The last two requirements are something difficult to achieve... for some reason, empty rows appear at the last positions of the datagrid. I post what i've managed to get:
    <mx:Script>
         <![CDATA[
         private function resize():void
                    if (dg.dataProvider)
                        var h:Number = dg.measureHeightOfItems( -1, dg.dataProvider.length);
                        dg.height = h;
         ]]>
    </mx:Script>
    <mx:DataGrid id="dg" width="530" horizontalCenter="0" verticalScrollPolicy="off"
            dataProvider="{dp}"
            wordWrap="true" variableRowHeight="true" showHeaders="false" dataChange="resize()" height="{dg.measureHeightOfItems(-1,dg.dataProvider.length)}" click="Alert.show(dg.rowCount.toString());">
            <mx:columns>
                <mx:DataGridColumn headerText="ID" width="50">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:TextArea height="{Math.random()*100}" wordWrap="true" backgroundColor="{Math.random() * 16777216}" paddingTop="0" paddingBottom="0"/>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>

    Thanks Harui, but it doesn't help. If the border is set it will help, but the very big problem is the empty rows that appear at the end of the datagrid... I can't find a way of measuring correctly the height of the itemRenderers!
    I'll update this thread if I manage to do it.

  • Advanced Datagrid - Summary Row without groupping

    I need to make a datagrid with a summary row on top of it. It
    works fine with the gropping tag inside of groupping collection.
    But i don't need groups - i need only summaries.
    When I white following code inside of Advanced - flex crashes
    and tell something like "cannot null blablala".
    quote:
    <mx:GroupingCollection id="smallMetricsDataProvider"
    source="{bigMetrics}">
    <mx:summaries>
    <mx:SummaryRow summaryPlacement="first">
    <mx:SummaryField dataField="@type" operation="COUNT"
    />
    <mx:SummaryField dataField="@budget"
    summaryFunction="MetricsUtils.varianceTotalCount" />
    <mx:SummaryField dataField="@raw"
    summaryFunction="MetricsUtils.varianceTotalCount" />
    </mx:SummaryRow>
    </mx:summaries>
    </mx:GroupingCollection>
    What can you advice 4 me?
    Thanks, Roman.

    Fine, I found a way how to do it, using renderprovider 4
    folder items with a null height =))).
    It's a hack, the bad hack, i hope it wold be improved...
    So, i have another problem - i want to get this summary
    values. How?
    Thanks, Roman.

  • How can i create a grid with summary row

    Hello Professionals,
    I'm wondering how could i create a grid like the grid below, i want to create a grid with summary row,
    i have tried to create it using collapsing but it didn't work as required.
    Any suggestions?, i want to know just the starting point so i can make deep investigations.
    Thanks in Advance,

    Hi Karem,
    this can be achieved by just assigning a datatable containing the data plus some formatting of grid. Meaning there is no feature for that.
    The datatable can be filled manually or by sql query. Then you have to attach some events for updating the values ( validate after for gid item ).
    A small example for a sql query showing last month quotations and orders with summary :
    select 1 as Sort,cast(DocNum as varchar) as DocNum,DocTotal,convert(varchar, DocDate,104) from OQUT where DocDate between  DATEADD(month, -1, GETDATE()) AND GETDATE()
    UNION ALL
    Select 2 as Sort,'Summary ( Quotation ) : ',sum(DocTotal), convert(varchar,  DATEADD(month, -1, GETDATE()),104)+' - '+convert(varchar,   GETDATE(),104) from OQUT where DocDate between  DATEADD(month, -1, GETDATE()) AND GETDATE()
    UNION ALL
    select 3 as Sort,cast(DocNum as varchar) as DocNum,DocTotal,convert(varchar, DocDate,104) from ORDR where DocDate between  DATEADD(month, -1, GETDATE()) AND GETDATE()
    UNION ALL
    Select 4 as Sort,'Summary ( Order ) : ',sum(DocTotal), convert(varchar,  DATEADD(month, -1, GETDATE()),104)+' - '+convert(varchar,   GETDATE(),104) from ORDR where DocDate between  DATEADD(month, -1, GETDATE()) AND GETDATE()
    ORDER by Sort
    regards,
    Maik

  • Strange Behaviour on DataGrid with ArrayCollection as DataProvider

    I have a Datagrid with an ArrayCollection as DataProvider, the arrayCollection is partially generated by a remoteObject call, the dataprovider seems to works at least until I try to edit the field...
    By the RemoteObject I only receive an ArrayCollection with the field `ip`, but the datagrid looks for the fields ip, check and save...
    If I add/edit this new field it works, but only under particular condition
    The DataGrid:
    <s:DataGrid id="datagrid" left="10" right="10" top="136"
           dataProvider="{listaIPCheck}" bottom="10" requestedRowCount="4">
              <s:columns>
                    <s:ArrayList>
                         <s:GridColumn dataField="ip" headerText="Asset"/>
                         <s:GridColumn dataField="check" headerText="Inventory"/>
                         <s:GridColumn dataField="save" headerText="Salvataggio"/>
                    </s:ArrayList>
               </s:columns>
    </s:DataGrid>
    The Script:
       [Bindable]private var listaIPCheck:ArrayCollection;
        private function ro_resultHandler(event:Event=null):void
          listaIPCheck = new ArrayCollection();
          listaIPCheck = ro.getListUpdate.lastResult;
          heap = 0;
          // Read Below {POINT #1}
          init3();
        private function init3():void
         // Read Below {POINT #2}
         if (heap<listaIPCheck.length)
            // omitted the initialization of the process p
            p.addEventListener(NativeProcessExitEvent.EXIT, onExit);
            try{
              p.start(startupInfo);
            }catch(e:Error){}
        private function onExit(e:NativeProcessExitEvent):void {
            // Read below {POINT #3}
    Here is my code, now as you can see there are 3 line where I wrote to read below...
    Let's assume to put this simple `for` instead of the commented line (once at a time)
        for (var k:Number=0;k<listaIPCheck.length;k++)
          listaIPCheck.getItemAt(k).check = "checkVal";
          listaIPCheck.getItemAt(k).save = "saveVal";
    This code always work in the 3 points, so at the end of the call the ArrayCollection is always filled with the new values, but the datagrid refresh the items only in POINT #1 and POINT #2
    Why not in Point #3???

    Thank you Amy, but adding the properties in the server side did not work...
    The workflow of the program is that:
    1) I get the ArrayCollection (listaIPCheck) contatining some information  (function ro_resultHandler)
    2) I start an external process and grab the output data (function init3)
    3) read and use the data from the process (function onExit)
    Now the problem I have is regarding the refresh of the datagrid, this datagrid has the ArrayCollection (listaIPCheck) as DataProvider.
    So:
    - If I put the for loop instead of the comments  ( // Read Below {POINT #1} ) or
    ( // Read Below {POINT #2} )  it works, the ArrayCollection is updated and the datagrid is refreshed
    - Whereas if I put the for loop instead of  ( // Read Below {POINT #3} ) , it won't work.. or at least, the ArrayCollection is correctly updated, but the datagrid is not refreshed at all and I have to use .refresh()

  • [svn:fx-trunk] 8507: Making measureHeightOfItemsUptoMaxHeight consistent with the way we create rows in the datagrid .

    Revision: 8507
    Author:   [email protected]
    Date:     2009-07-10 10:13:11 -0700 (Fri, 10 Jul 2009)
    Log Message:
    Making measureHeightOfItemsUptoMaxHeight consistent with the way we create rows in the datagrid. MakeRow ensures reported row height is round to the nearest integer, measureHeightOfItemsUptoMaxHeight is now consistent.  Fixes a long standing PrintDataGrid issue.
    Bugs: SDK-20237.
    QE Notes: None
    Doc Notes: None
    Reviewer: Glenn/Alex
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-20237
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/DataGrid.as

    Well, you could do the following:
    1) Create a stored procedure that assembles the data into a rowset with rows and fields like the format you want.
    2) Create stored procedures that handle insert, update, and delete.
    3) Create an entity object definition with all transient attributes. Make the attributes match the elements of one row.
    4) Override doDML() in the entity object class to call your procedures (the doc explains how to do this). You might also need to do a bit of research and figure out if you need to override some other method so you can report rows with transient attribute changes only as needing posting. (getPostState(), maybe?)
    5) Create a view object definition with entity-derived attributes based on your EO attributes.
    6) Override the appropriate methods to call your data assembly procedure rather than execute a query (this is also in the doc).
    Still kind of kludgy, but it keeps your business components pretty clean, especially if you use framework classes to do most of the work for you. (I have a partial example of how to do that here.) Of course, it keeps your business components clean by moving the real work to the DB, but some people find that more maintainable that a kazillion business components.
    Hope this helps,
    Avrom

  • AdvancedDatagrid with a summary row

    Hello,
    I have an AdvancedDatagrid with two grouping fields in a
    summary row.
    Everything works fine when there is no labelFunction
    associated with it.
    But as soon as I specify a labelFunction, the summary row
    fields are empty. I need a labelFunction to format dates and
    numbers.
    How to write a proper labelFunction for an AdvancedDatagrid
    with a summary row ?
    Regards,
    Karl.

    Okay, I figured it out.
    Now, I have two label functions set at the
    AdvancedDataGridColumn level for the summary row fields and one
    labelFunction set at the AdvancedDataGrid level for all the other
    fields.
    <mx:AdvancedDataGridColumn id="amountTotal"
    dataField="sumAmount" labelFunction="sumAmountLabelFunction" />
    <mx:AdvancedDataGridColumn id="collectedTotal"
    dataField="sumCollected" labelFunction="sumCollectedLabelFunction"
    />
    In order to avoid a null pointer exception on the sumAmount
    and sumCollected fields in the label function, I use the
    hasOwnProperty() method to check before access. Otherwise, this
    exception will happen while expanding the tree.
    private function sumAmountLabelFunction(item:Object,
    column:AdvancedDataGridColumn):String
    if(item.hasOwnProperty("sumAmount"))
    return this.numberFormatter.format(item.sumAmount);
    return "";
    private function sumCollectedLabelFunction(item:Object,
    column:AdvancedDataGridColumn):String
    if(item.hasOwnProperty("sumCollected"))
    return this.numberFormatter.format(item.sumCollected);
    return "";

  • DataGrid with multi-row headers

    Hello!
    How can I have a DataGrid with header and sub-headers so to speak.
    Something like this:
    [     Main Header     ]
    [ sub1] [sub2] [sub3]
    Thanks!

    There is a SplitDataGridColumn example on my blog
    Alex Harui
    Flex SDK Team
    Adobe System, Inc.
    http://blogs.adobe.com/aharui

  • DataGrid with dynamic comboboxes

    I need to design a dataGrid with comboboxes in one column. These comboboxes should all have different dataProviders based on a value from column 1. What would a general approach be?
    Thanks

    The renderer's data property is the data for the entire row so you can get the column1 data and assign the combobox's dataprovider accordingly.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Adding a dynamic summary row for a spark data grid

    i'm looking for a solution for a spark data grid.
    by clicking on a row it will become larger and will show under the original row a some kind of a summary text with no realtion to columns.
    is there a summary row option for a spark datagrid that can shown by clicking on the row?

    Why would you need to make this part of the DataGrid? Just create some kind of view and bind it's data to the selectedItem of the DataGrid.
    *edit*
    Ohhhh, I see that you want it to display under the item. I believe you can do what you need in the skin, but I haven't had a chance to use the spark DataGrid yet so I can't say for sure. I know it has a feature to skin the selection, so I'm sure you can use that to do what you need.

  • Combobox in Datagrid with different values

    Hi All,
    I have a datagrid. One of the columns in the datagrid is set
    to display a combobox as the ItemRenderer. Now, the data for the
    combobox is different for each row. How do I set up the data
    provider for the combobox in such a scenario.
    For example : I have a collection of Shirt objects.
    public class Shirt {
    public String id;
    public String type;
    public String[] color; //this is an array
    This should be displayed in the datagrid, with the Color
    column rendered as a combobox. The colors will be different for
    each shirt.
    Thanks
    CS

    Yes. Some more detail:
    in the function,
    override public function set data(value:Object): void {
    the "value" parameter will contain a refernce to an entire
    "Shirt" instance.
    So you can assign the comboBox.dataProvider=value.color;
    Now, It is more complicated than this, because you will want
    the combobox to show the correct value for each row, right?
    For this to happen, you will need a selectedColor property on
    Shirt. When the user chooses a color, you will need to update this
    property with the selection.
    Next, your renderer must read the value of selectedColor and
    set the comboBox.selectedIndex.
    If selectedColor contains the *index* of the color then you
    have it easy. If it contains the color name itself, then you will
    have to for-loop over the color array until yom match the
    selectedColor. then you will have the index and can set
    selectedIndex.
    ComboBox does not support setting the value directly. It is
    pretty easy to extend combo to do this. There are several examples
    out there. I posted a link to one on CFLEX.net
    Tracy

  • Reloading a datagrid with all its records

    Hi,
    Could someone please tell me how to reload all the records of
    a datagrid without having to reload the entire page. I'm using an
    XML file (e4x format) to populate a datagrid. Some rows of this
    datagrid get deleted during runtime and at some point I would like
    to be able to reload the datagrid with all its records. If you have
    some code and detailed explanation (I'm a newbie) that would be
    greatly appreciated. Thank you very much for your help.
    Olivia

    Hi Greg,
    The XML file is called like this: <mx:XML id="DataTbl2"
    format="e4x" source="DataTbl2.xml"/>
    And used in the Datagrid as follow:
    <mx:DataGrid id="impDG"
    rowCount="{getLengthOfXmlArray2(DataTbl1..Option.(Imchecked ==
    true))}" visible="true" dataProvider="{DataTbl2.Option}"
    editable="false" x="24" y="134" width="611">
    I tried impDG.dataProvider.refresh() and it doesn't work. I
    also tried DataTbl2.Option.refresh(); and I get an error during
    runtime: TypeError: Error #1006: value is not a function.
    What do you mean by "collection". I'm not using any array
    collection, just an xml file to populate the grid.
    Thank you for your help,
    Olivia

Maybe you are looking for