4 Replies Latest reply on Jun 9, 2006 5:44 AM by mae_ling

    array of objects into dataset and then to datagrid

    sneakyimp Level 2
      I have discovered amfphp ( http://amfphp.org). It's a really cool way to move complex data objects from php to flash and back.
      quote:


      So I am successfully creating an array of items from my database...an item that would otherwise be created like this:
      items = array();
      item[0] = new Object();
      item[0].id = 7;
      item[0].name= "Item 1";
      item[0].styleNumber = "001";
      item[1] = new Object();
      .
      .
      .
      etc.



      I put DataSet and DataGrid objects on my stage called productDataSet and productDataGrid, respectively, and tried this:

      quote:


      this.productDataSet.items = re.result;
      trace('dataSet length:' + this.productDataSet.getLength());
      this.productDataGrid.dataProvider = this.productDataSet.dataProvider;



      the trace appears to work correctly--several hundred items--and the dataGrid shows my object property names (albeit in reverse order) and the DataGrid appears to have several hundred items in it but there is NO DATA THERE. All the list items are blank.

      I've had a bit of luck working with the component inspector creating bindings and stuff but I'm hampered by my incomplete understanding of how it works. All the tutorials I've found instruct me to import an XML sample to create a schema. Since I have no XML i cannot one.

      I want to do just a couple of things:
      1) put my data in the DataSet properly, ideally in one fell swoop--i *think* i've done this correctly above
      2) attach the DataGrid to the DataSet so that when i sort or filter the data set, the datagrid shows the results and when i select an item in the DataGrid, the DataSet knows that is the currently selected item.
      3) hide the 'id' field in the data grid and display user-friendly names for the columns: "Style Number" rather than "styleNumber".

      Any help would be much appreciated. I *think* this is all about understanding schemas but I don't really know.