actionscript 3 - how to assign dataProvider to DataGrid Dyanmically in flex? -


I did as follows

Brings data of a special method to me, as my parameter is that method For now,

Now I want to get the data from the related table and also to send the list, and return the flex and dynamically add the grid & amp; Dynamically add DATPOVIDER to its customized table in the Colomlex Flex side?

Remote Object (Java Class)

  Public List & lt; List & lt; String & gt; & Gt; GetMasterTableData (String Name) {String DesignMaster = "tbl_design_master" + name; String mastertable name = "tbl_master" + name; String [] [] res; & Lt; From the list & lt; String & gt; & Gt; List = New Arrestist & lt; List & lt; String & gt; & Gt; (); Try {st = connection.createStatement (); ResultSet rs1 = st.executeQuery ("Choose + to + + + Design Master"); Int len ​​= 0; While (rs1.next ()) {len ++; } ResultSet rs2 = st.executeQuery ("Choose + to +" + MasterTableName); While (rs2.next ()) {list & lt; String & gt; Ll = new ArrayList & lt; String & gt; (); For (int i = 1; i  

Flex code:

   & Lt; Mx: Method Name = "getMasterTableData" result = "getMasterTableDataRH (event)" error = "FH (event)" /> & Lt; / Mx: RemoteObject & gt; & Lt; Mx: script & gt; & Lt ;! [CDATA [[Bindabal] Pvt Works AC: Arraycution = New Arrayation (); Public work init (str: string): zero {RO.getMasterDesign (str); Application.application.selectedgridItem = Str; RO.getMasterTableData (Str); } Private Function getMasterDesignRH (Event: ResultEvent): Zero {Application.application.designList = Event. Results as ArrayCollection; Var aColumns: Array = new Array (); (Var i: int = 0; i for Application.application.designList.length; i ++) {var dgc: DataGridColumn = New DataGridColumn (); Dgc.headerText = Application.application.designList.getItemAt (i) .colName; //dgc.dataField = Application.application.designList.getItemAt (i) .colName; AColumns.push (DGC); } MainGrid.column = A column; } Private function getMasterTableDataRH (Event: ResultEvent): zero {ac = event.result ArrayCollection; MainGrid.dataProvider = AC; } Private Function FH (Event: Fault Event): zero {alert.show (event.fault.faultString); }] & Gt; & Lt; / Mx: script & gt; & Lt; Mx: hbox width = "100%" height = "80%" & gt; & Lt; Mx: DataGrid ID = "Main grid" width = "100%" height = "100%" /> & Lt; / Mx: hbox & gt;  

getMasterDesign is an ArrayCollection, which is filled with column names and components to display

Ex: getMasterDesign (emp) empMasterDesign table looks like this

  colName component -------------------- EPNname text box empSal text box empDesi combobox empMasterData: empName | EmpSal | EmpDesi abc 1000 cler ## heading ## ck xyz 2000 Manager  

Now I want to dynamically create a datagrid in Flex using its design. I have done everything in the Major Data Table Action Script, my datagreat was created for its master design, but the data is not visible?

You have to set dataField in the appropriate code. From the given data, it seems that the colName field and its associated names in the metadata are not the same in the table, for example it's the EmpName in the original code and the EmpName is ; None of the fields match - empSal vs EmpSal , empDesi versus EmpDesi . Fix it, assign colName to the Datafield, and it would be nice to go.


Comments