3 Replies Latest reply on Feb 17, 2009 8:27 AM by rtalton

    DataGrid

    kylesaid
      How would I go about setting the first column of a DataGrid to equal a specific variable from a Value Object? Specifically, I would like to set a count variable to be the first column to show how many rows are in the DataGrid. The dataProvider for this DataGrid is coming from a Java Value Object via BlazeDS.

      Is there an easier way to do this? It seems like having a column to display the row count would be a default property of a table or DataGrid.
        • 1. Re: DataGrid
          rtalton Level 4
          If you want to implement row or line numbering, here's help:
          http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1409543
          • 2. Re: DataGrid
            kylesaid Level 1
            Does this still apply for dynamically generated columns? Right now i'm just pulling in an ArrayList that contains a value object for each row in the DataGrid. Can you add one column for the row index without specifying the rest of the columns? Examples like the one below are fine and dandy but I wont know the exact column names (or even the total amount of columns) coming from the ArrayList/Java Value Object.

            quote:


            <?xml version="1.0"?>
            <!-- itemRenderers\dataGrid\myComponents\RendererDGListData.mxml -->
            <mx:TextArea xmlns:mx=" http://www.adobe.com/2006/mxml"
            preinitialize="initTA();">

            <mx:Script>
            <![CDATA[

            import mx.controls.dataGridClasses.DataGridListData;
            import flash.events.Event;

            public function initTA():void {
            addEventListener("dataChange", handleDataChanged);
            }

            public function handleDataChanged(event:Event):void {
            // Cast listData to DataGridListData.
            var myListData:DataGridListData =
            DataGridListData(listData);

            // Access information about the data passed
            // to the cell renderer.
            text="row index: " + String(myListData.rowIndex) +
            " column index: " + String(myListData.columnIndex);
            }
            ]]>
            </mx:Script>
            </mx:TextArea>




            Also, the DataGrid seems to be sorting everything in alphabetical order. Or do you think the sort is happening on the ArrayList or the Value Object?
            • 3. Re: DataGrid
              rtalton Level 4
              quote:

              Does this still apply for dynamically generated columns?

              Yes, it should.
              quote:

              Can you add one column for the row index without specifying the rest of the columns?

              Yes, you can build the Data Grid dynamically with any number of columns you wish.
              quote:

              Also, the DataGrid seems to be sorting everything in alphabetical order. Or do you think the sort is happening on the ArrayList or the Value Object?

              The Data Grid does not sort the data unless you tell it to. The data is probably being sorted on the server-side.