3 Replies Latest reply on Dec 13, 2010 3:25 PM by Peter deHaan

    Spark DataGrid Help

    mdmave Level 1

      Where does one look to find examples on the Spark DataGrid? I know its bleeding edge but I can't find much info on how to use it.

       

      Specifically, I have two arrays: One with the column data such as [['name', 'string'], ['age', 'int']] and another with row data, such as [[dave, 30], [ray, 29], [jason, 25], [sara, 30]].

       

      I'd like to have a datagrid bound to these arrays, but not sure how. I'm building a dynamic data browser and it would help to have some info around setting columns dynamically. I played around with creating one array, and giving it objects such as columns, and rows with the data outlined above. Thats not helping either.

      THanks for any direction,

      D

        • 1. Re: Spark DataGrid Help
          Peter deHaan Level 4

          Not sure about your exact nested array example, but here is a basic example on how to use your data in a Spark DataGrid control:

          <s:DataGrid>

              <s:columns>

                  <s:ArrayList>

                      <s:GridColumn dataField="name" />

                      <s:GridColumn dataField="age" />

                  </s:ArrayList>

              </s:columns>

              <s:dataProvider>

                  <s:ArrayCollection>

                      <fx:Object name="dave" age="30" />

                      <fx:Object name="ray" age="29" />

                      <fx:Object name="jason" age="25" />

                      <fx:Object name="sara" age="30" />

                  </s:ArrayCollection>

              </s:dataProvider>

          </s:DataGrid>

           

           

          Peter

          • 2. Re: Spark DataGrid Help
            mdmave Level 1

            Thanks Peter,

            I should have been more clear the data/arrays that I am using are brought back from a separate class asynchronously:

             

            var tableName:String = event.currentTarget.selectedItems[0];

            tableMap[tableName] = {};

             

            controller.getTableInfo(tableName, function(data:Array):void

            {

            tableInfo.source = data.map(function (element:RowData, index:int, array:Array):String {

            return element.getColumnAsString(1) + " (" + element.getColumnAsString(2) + ")";

            });

             

            tableMap[tableName].label = tableInfo;

            dataGrid.columnHeaderBar.labelField = "label";

            });

            controller.selectAll(tableName, function(data:Array):void

            {

            tableMap[tableName].data = data;

            dataGrid.dataProvider = new ArrayCollection(tableMap[tableName].data);

            });

             

            Right now I am close, but the column headings all say [object GridColumn]

             

            thanks

            • 3. Re: Spark DataGrid Help
              Peter deHaan Level 4

              I'm really not sure, unless you can paste a simple 20+/- line example that I can try and play with.

              I can honestly say that this isn't something I personally have tried doing when testing the Spark DataGrid.