Flex : How to display a DataGrid selectedItem's details in a Form -


Sorry for this long post. The question is small, but the full details are required. Thanks for reading and helping :)

I used the HTTPService POST method to call a PHP file that gives me the result of an XML type like

  & Lt; User & gt; & Lt; Name & gt; Jones & lt; / Name & gt; & Lt; Age & gt; 34 & lt; / Age & gt; & Lt; / User & gt;  

This result is obtained after php files are asked for a database. Database also has other information (height, gender, education and address)

I now have dataprovider = "{userRequest.lastResult.User}" datagrid (two columns: name and age) and a form Using the attribute, the above xml data is displayed in the datagrid. I

I now use the itemclick = itemClickEvent (event) C I do so when a user clicks on the second row of Detagrid related line went click (height, gender, has been placed under the data grid GUI which can be seen in education etc.) form. For now my itemsclick events look like,:

  Private Function ItemsClick Event (Event: List Event): Zero {clickRow.text = string (event.rowIndex); // I do not know I should assign the following label ... //height.text= //gender.text= //edu.text=}  

form structure:

Is there a way that I can access XML data from itemClickEvent function ? Given that the DataGrid structure header

  & lt; Mx: DataGrid id = "dgUserRequest" data provider = "{userRequest.lastResult.user}" x = "28.7" y = "36" width = "525" height = "149" item = "itemclive event"); " & Gt;  

and the HTTPS service title

  & lt; Mx: HTTPService id = "userRequest" url = "request.php" method = POST ">  

is a part of the related $ Php file:

  if ($ _ POST ['getResult'] == 'send') {$ result = mysql_query ("select from user interface"); $ Return = "& Lt; UserInfo & gt; "; While ($ line = mysql_fetch_object ($ result)) {$ return. =" & Lt; Users & gt; & Lt; Name & gt; "$ Line-> Names." & Lt; / Name & gt; & Lt; Age & gt; "$ Line-> Age." And  gt; & Lt; Height & gt; "$ Line-> height." & Lt; / Height> & Lt; Gender & gt; "$ Line-> gender." & Lt; / Jword & gt; & lt; education & gt; "$ row- & gt; education." & Lt; / education & gt; & lt; / user & gt; "$ Return. =" & Lt; / UserInfo & gt; "; Mysql_free_result ($ result); print ($ Return);  

}

If you are using the data provider as your userRequest.lastResult.user.name for the data grid, your dataField What's in the name and age column?

There is one more easy way to do this. Suppose the xml structure is something similar:

  & lt; someRootTag & gt; & Lt; Users & gt; & lt; Name & gt; jones & lt; / name & gt; & gt; Age & gt; 34 & lt; / age & gt; & lt; height & gt; 180 & lt; / Height> gt; & lt; / user & gt; & lt; use Guy & gt; & lt; Name & gt; John & lt; / Name & gt; & gt; Age & gt; 4 & lt; / age & gt; & lt; height & gt; 100cm & lt; / height & Gt; & lt; / Users & gt; & lt ;! - more & lt; user / & gt; tag - & gt; & lt; / someRootTag & gt;  

Note that the resultFormat of HTTPService is in the e4x default object

& lt; Mx: HTTPService id = "service" url = "data.xml" as a result = "e4x" /> & Lt; Mx: Datagreat id = "dg" data provider = "{service.lastResult.user}" & gt; & Lt; Mx: column & gt; & Lt; Mx: Datagreat column datafield = "name" /> & Lt; Mx: DataGrade column datfold = "age" /> & Lt; / Mx: column & gt; & Lt; / Mx: data grid & gt; & Lt; Mx: form & gt; & Lt; Mx: form item label = "name" & gt; & Lt; Mx: text input text = "{dg.selectedItem.name}" /> & Lt; / Mx: FormItem & gt; & Lt; Mx: formystem label = "age" & gt; & Lt; Mx: text input text = "{dg.selectedItem.age}" /> & Lt; / Mx: FormItem & gt; & Lt; Mx: formitium label = "height" & gt; & Lt; Mx: text input text = "{dg.selectedItem.height}" /> & Lt; / Mx: FormItem & gt; & Lt; / Mx: form & gt;

You only have to call the AS code from service.send () to creationComplete .


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -