2 Replies Latest reply on Aug 30, 2010 1:26 PM by Devtron

    NULL Text problem with DataGrid SelectedItems

    Devtron Level 3

      Hello,

       

      I need to create a string based on the name property on rows in a DataGrid.

       

      here is my code:

       

                          //get devices names

       

                          var idx:uint;

       

                          var len:uint = dg.selectedItems.length;

       

                          var deviceNames:String;

       

                          for (idx = 0; idx < len; idx++) {

       

                              deviceNames += dg.selectedItems[idx]["name"].toString() + ", ";

       

                          }

       

       

      Whenever I trace or display the deviceNames string, it has "null" at the beginning, like this:

      "nullDevice1, Device2, "

       

      Why is null appearing? I have tried to remove it, replace it, and nothing.

       

      I know you can use replace or concat, but neither of those work. There are only two rows in my datagrid. I dont know why NULL is even appearing at the beginning of the string. I have changed the loop dimensions, because I thought maybe it was not zero-based, but still no luck.