2 Replies Latest reply on Aug 19, 2009 5:03 AM by Cybernavy

    Summary Row on adv. datagrid with no dataprovider

    Cybernavy

      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

       

       

        • 1. Re: Summary Row on adv. datagrid with no dataprovider
          paul.williams Level 4

          Looking at the source code for the ADG, it looks like an empty array is

          created as a dataProvider if you haven't assigned one (take a look at

          'dragDropHandler' of AdvancedListBase).

           

          However, I would suggest assigning an empty dataProvider yourself. Total

          price aside, I imagine you'll eventually need to retrieve the chosen

          items out of your shopping cart in order to submit the order.

          • 2. Re: Summary Row on adv. datagrid with no dataprovider
            Cybernavy Level 1

            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>