2 Replies Latest reply on Sep 7, 2007 12:27 PM by pzh19z

    DataGrid data binding issues

      I'm trying to create a DataGrid in code and populate it with information. The final product I'm trying to create is a form that displays the files you selected after browsing your computer. I plan to place the FileReferenceList informaiton into an array that will become the DataGrid's dataProvider.

      Would someone please let me know what I'm doing wrong, or provide a link to a great resource on how to create and use DataGrids with Actionscript 3?

      I keep getting the following error;

      "ArgumentError: Error #1063: Argument count mismatch..."

      This error occurs during the binding process of the dataProvider method.

      Below is an example of the relevant code I'm trying to use;

      var _dgFiles:DataGrid = new DataGrid();
      _dgFiles.allowDragSelection = false;
      _dgFiles.allowMultipleSelection = true;
      _dgFiles.resizableColumns = false;
      _dgFiles.sortableColumns = false;
      _dgFiles.percentWidth = 100;
      _dgFiles.percentHeight = 100;

      var aColumns:Array = _dgFiles.columns;

      var dgcIcon:DataGridColumn = new DataGridColumn();
      var dgcName:DataGridColumn = new DataGridColumn();
      var dgcSize:DataGridColumn = new DataGridColumn();
      var dgcFile:DataGridColumn = new DataGridColumn();

      dgcIcon.headerText = "";
      dgcIcon.dataField = "icon";
      dgcIcon.width = 26;
      dgcIcon.editable = false;
      dgcIcon.resizable = true;
      dgcIcon.visible = false;

      dgcName.headerText = "File";
      dgcName.dataField = "name";
      dgcName.editable = false;
      dgcName.resizable = true;

      dgcSize.headerText = "Size";
      dgcSize.dataField = "size";
      dgcSize.width = 50;
      dgcSize.editable = false;

      dgcFile.headerText = "Data";
      dgcFile.dataField = "data";
      dgcFile.wordWrap = false;
      dgcFile.editable = false;
      dgcFile.visible = false;

      _dgFiles.columns = aColumns;


      var a1:Array = new Array({icon:"*.jpg",name:"FileName1.jpg",size:10002,data:"TEST1"});
      var a2:Array = new Array({icon:"*.jpg",name:"FileName2.jpg",size:10002,data:"TEST2"});
      var a:Array = new Array();
      _dgFiles.dataProvider = a;

      // This is where it fails. I think my test array "a" is not correct. How do I provide the correct information to the
      // DataGrid so that it works?
        • 1. Re: DataGrid data binding issues
          I think there's an error where you're combining the arrays:


          is actually creating a 2-dimensional array, instead of concatenating them into a single array. Is that what you intended?

          For a datagrid, you want an Array/ArrayCollection of objects.

          I copied and pasted your code and changed the array part to this:

          var data:Array = new Array(

          _dgFiles.dataProvider = new ArrayCollection(data);

          And it works as (I think) you want.
          • 2. DataGrid data binding issues
            pzh19z Level 1
            Wrong Thread...