2 Replies Latest reply on Aug 11, 2009 4:27 AM by re-Flexing

    How can I pass a value from the datagrid to my textinput


      Hi i am new in adobe flex!

      I have only one row in my datagrid and it has 5 dataField. Those dataFields are id, ln, fn, kurs, yr. I want to pass those value into a textinput respectively.

      Heres my code:


      <mx:DataGrid x="396" y="10" width="110" height="124" id="dginfo" enabled="true" dataProvider="{studinfo.lastResult.datas.data}" creationComplete="studinfo.send()" editable="false" visible="true">
                                  <mx:DataGridColumn headerText="C0" dataField="username" visible="false"/>
                                  <mx:DataGridColumn headerText="C1" dataField="id"/>
                                  <mx:DataGridColumn headerText="C2" dataField="ln"/>
                                  <mx:DataGridColumn headerText="C3" dataField="fn"/>
                                  <mx:DataGridColumn headerText="C4" dataField="kurs"/>
                                  <mx:DataGridColumn headerText="C5" dataField="yr"/>



      I want to pass it here (code)


      <mx:TextInput backgroundColor="#ABA5A5" editable="false" enabled="true" color="#000000" horizontalCenter="-50" verticalCenter="-71" id="idview" text="{data.id}"/>
                          <mx:TextInput  id = "idview" editable="false" enabled="true" text="{data.ln}"/>
                          <mx:TextInput  id="lnview"editable="false" enabled="true"text="{data.fn}"/>
                          <mx:TextInput id="fnview" editable="false" enabled="true" text="{data.kurs}"/>
                          <mx:TextInput backgroundColor="#ABA5A5" editable="false" enabled="true"  id="yrview" text="{data.yr}"/>


      My problem is that this code won't work, it won't diplay anything...:D

        • 1. Re: How can I pass a value from the datagrid to my textinput
          Madhav Subedi Level 4

          it must not display anything as data.ln doesnot have any value. in your code, in the text property of textfield, data is considered as a property of your application, a dynamic object; so even it doesnot have ln property, it is not showing error, neither displaying anything.



          do you mean to populate your textfields if the datagrid row is selected? if so:


          <mx:TextInput  id = "idview" editable="false" enabled="true" text="{dginfo.selectedItem.ln}"/>







          if you want to populate the same data without caring if it is selected in datagrid, you should not think like you are getting data from datagrid, instead, you are getting your values directly from the studinfo.lastResult


          in such:


          <mx:TextInput  id = "idview" editable="false" enabled="true" text="{studinfo.lastResult.datas.data.ln}"/>






          note: if your result contains more than one data, you should treat it as array:


          • 2. Re: How can I pass a value from the datagrid to my textinput
            re-Flexing Level 1

            thanks man! That's what I'm looking for!!

            you save my day!

            Keep it up...