4 Replies Latest reply on Jun 11, 2007 3:05 PM by SUNITAR

    Flex datagrid help

    SUNITAR
      Hi,

      I have a datagrid which is showing the products and their decsription , price etc. I want to do this: When a user select one item in the datagrid it will show the components in a small window or something , those are not showing in the datagrid. I populate the datagrid from a sql server table by remote object. How can I do this ? Please help. I am a newbe.. Thanks in advance.
        • 1. Re: Flex datagrid help
          SA_TPS Level 1
          Hey there,

          Create your Text boxes in which you want to display the data in and put this in:

          <mx:TextArea x="344" y="9" height="19" width="209" text="{myDataGrid.selectedItem.Property }" id="addressText"/>

          Where "Property" is the name of the "dataField" in your "DataGridColumn" declaration.

          Hope that helps!
          • 2. Re: Flex datagrid help
            SUNITAR Level 1
            Thanks so much for your reply. But one item can have more than one components. When the user select the item in the grid I need to select the components from another sql server table and show them in a grid or tree or something. How can I do this ?
            Thanks..
            • 3. Re: Flex datagrid help
              SA_TPS Level 1
              Right. Here's my DataGrid:

              <mx:DataGrid width="876" height="264" id="myDataGrid" dataProvider="{userRequest.lastResult.enter.reg}">
              <mx:columns>
              <mx:DataGridColumn headerText="Last Name" dataField="lName" width="150"/>
              <mx:DataGridColumn headerText="First Name" id="fName" dataField="fName" width="150"/>
              <mx:DataGridColumn headerText="Phone" dataField="Phone" width="150"/>
              <mx:DataGridColumn headerText="Vehicle" dataField="Vehicle"/>

              </mx:columns>
              </mx:DataGrid>


              You'll notice the dataProvider="{userRequest.lastResult.enter.reg} which is where you get the data from the SQL database.

              Now, you'll see this:

              <mx:TextArea x="103" y="9" width="177" height="19" id="fNameText" text="{myDataGrid.selectedItem.fName}"/>
              <mx:TextArea x="103" y="35" height="19" width="177" id="lNameText" text="{myDataGrid.selectedItem.lName}"/>
              <mx:TextArea x="103" y="61" height="19" id="phoneText" text="{myDataGrid.selectedItem.Phone}"/>
              <mx:TextArea x="103" y="87" height="19" width="177" id="emailText" text="{myDataGrid.selectedItem.Email}"/>
              <mx:TextArea x="344" y="9" height="19" width="209" text="{myDataGrid.selectedItem.Address}" id="addressText"/>
              <mx:TextArea x="344" y="35" height="19" width="209" text="{myDataGrid.selectedItem.City}" id="cityText"/>
              <mx:TextArea x="344" y="61" height="19" width="209" text="{myDataGrid.selectedItem.State}" id="stateText"/>
              <mx:TextArea x="344" y="87" height="19" width="82" text="{myDataGrid.selectedItem.Zip}" id="zipText"/>
              <mx:TextArea x="605" y="10" height="18" width="109" text="{myDataGrid.selectedItem.Date}" id="dateText"/>
              <mx:TextArea x="605" y="35" height="19" width="109" text="{myDataGrid.selectedItem.Time}" id="timeText"/>

              Notice the {myDataGrid.selectedItem.****}, the ****'s are the name of the database field you passed in from SQL.

              Basically what that did was I had a DataGrid with only 4 of the values showing that I wanted, then had a separate panel where the other fields displayed.
              • 4. Re: Flex datagrid help
                SUNITAR Level 1
                Yes, this will work if you are selecting all the columns from the database and showing a few. But my problem is I am not selecting the components at all. I am selecting item, description , price etc. from a table. In the item , there are some 'Combo'
                items which have related 3,4 or 5 components in another table . It can be linked one-to many. One combo can have more than one components. In my grid I am not showing the components. When the user will select an item I will have to query the database to get the components for that 'combo' and show it in a small window so the user can view what are the components or the child items for this 'combo' item. I am just trying to figure out how I can do this..
                Thanks..