3 Replies Latest reply on Apr 14, 2010 10:57 PM by Sameer Bhatt

    Editable AdvancedDataGrid / Read-only SummaryRow

    FlexVexed

      tl;dr - How do I have read-only SummaryFields for an editable column in the AdvancedDataGrid?

       

      I have an AdvancedDataGrid based on flat data in a GroupingCollection that groups on one field (named "day"). There are 2 known read-only columns, and N additional columns (N is equal for all rows in the grid). My goal is to have the N additional columns editable (numeric) with a read-only SummaryRow at the group level for those columns.

       

      I can display everything properly, but I cannot figure out how to make the SummaryRow read-only.

       

      AdvancedDataGrid and AdvancedDataGridColumn seems to the be only classes that allow you to toggle an "editable" flag.

       

      When I use an AdvancedDataGridRendererProvider, my custom Label-based renderer is called, but I do not know which column it is being called for, so even though I have access to the child data, I do not know which fields in the children to summarize and display in the text field of the label.

       

      Data is in an ArrayCollection where each item (row) has the following format:

      {

           "day": 1,

           "hour": "Shift 1",

           "Skill0": 4,

           "Skill1": 8,

           "Skill2": 15,

           "Skill3": 16,

           "Skill4": 23,

           "Skill5": 42

      }

      where "day" is the column the grouping occurs on, "day" and "hour" are displayed as read-only fixed columns, and the "SkillN" fields are displayed as editable columns.

       

      SummaryRow.jpg

       

      I hope I am missing some simple bit of information here. I have spent many hours on this!

       

      Am I approaching the solution wrong? Hints and advice are appreciated!

       

      Thanks,

      Matt

        • 2. Re: Editable AdvancedDataGrid / Read-only SummaryRow
          FlexVexed Level 1

          Thank you so much, Sameer. Unfortunately, I have not been able to get this working. I am using SDK 3.5 in Flex Builder 3.

           

          Below is a sample app that shows the "editable" property not working properly. Here is a screenshot of the result showing that the summary row is editable:

          editableNotWorking.jpg

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
            <mx:AdvancedDataGrid initialize="gc.refresh()" editable="item">
              <mx:dataProvider>
                <mx:GroupingCollection id="gc">
                  <mx:source>
                    <mx:ArrayCollection>
                      <mx:Object day="1" hour="1" Skill0="1"/>
                      <mx:Object day="1" hour="2" Skill0="1.5"/>
                      <mx:Object day="1" hour="3" Skill0=".25"/>
                    </mx:ArrayCollection>
                  </mx:source>
                  <mx:grouping>
                    <mx:Grouping>
                      <mx:GroupingField name="day">
                        <mx:summaries>
                          <mx:SummaryRow summaryPlacement="group">
                            <mx:fields>
                              <mx:SummaryField dataField="Skill0"/>
                            </mx:fields>
                          </mx:SummaryRow>
                        </mx:summaries>
                      </mx:GroupingField>
                    </mx:Grouping>
                  </mx:grouping>
                </mx:GroupingCollection>
              </mx:dataProvider>
              <mx:columns>
                <mx:AdvancedDataGridColumn dataField="day"/>
                <mx:AdvancedDataGridColumn dataField="hour"/>
                <mx:AdvancedDataGridColumn dataField="Skill0"/>
              </mx:columns>
            </mx:AdvancedDataGrid>
          </mx:Application>

          • 3. Re: Editable AdvancedDataGrid / Read-only SummaryRow
            Sameer Bhatt Adobe Employee

            Seems like a bug. Can you log it.

             

            If you have the  source for AdvancedDataGrid, you can make it working by changing - AdvancedDataGridBaseEx.mouseUpHandler()

            Change  this statement -

                    else if (lastItemDown && lastItemDown != itemEditorInstance)
            

            to  -

                    else if (lastItemDown && lastItemDown != itemEditorInstance && isDataEditable(r.data))
            

             

            Please  note that this is not an official tested fix, though it seems to work  well for your sample.