5 Replies Latest reply: Jul 4, 2014 12:16 PM by Michelle5002 RSS

    DataGrid with only one record

    Michelle5002

      I have a master table on one server and is services by a session bean.   I have the detail data on a second server and is services by another session bean.   So, I have a dataGrid which displays the master table and then when a record is selected in the master data Grid, then a request is sent out to fetch the detail data from the second server.   And as long as there are more than one detail records for the selected Master record, the second data grid displays this data fine.   But if there is only one detail record, for some reason the detail dataGrid is not updated.   And as of Now, if the first selection only has one record, then it displays nothing.  Which it should display at least the one record.  If you select one which has more than one detail record and then select one which only has one detail record, it displays the last set of detail records which had more then one record.   Which is incorrect.   Its as if the call to fetch the new set of records was never called.   And yet if I select a master record which has more than one detail record and then select another master record which also has more than one detail record, then it displays correctly.  

       

      My master datagrid has a selection change handler which is where I am calling the fetch for the detail data:

       

         protected function peopleGrid_selectionChangeHandler(event:GridSelectionEvent):void
         {
         getPlacesResult.token = cSOracleBean.getPlaces(peopleGrid.selectedItem.id);
         }
        

       

      on the detail datagrid, this is the databinding:

          <s:AsyncListView list="{getPlacesResult.lastResult}"/>
        • 1. Re: DataGrid with only one record
          Michelle5002 Community Member

          I just realized I pretty much asked this same question twice now.   Nobody answered this one.   surely I am not the first person to run into this issue.

          • 2. Re: DataGrid with only one record
            pauland Community Member

            I haven't used flex for some time, but the result will not be a collection but a single item. If I remember correctly the trick is to create a collection, put the item inside that and assign the grid datasource using that collection..

            • 3. Re: DataGrid with only one record
              Michelle5002 Community Member

              Okay, I created a protected variable and then changed the datagrid to this

              <code>

              <s:DataGrid id="placesDG" x="10" y="160" width="1050" height="150"
                   editable="true"
                   dataProvider="{placesList}"
                   creationComplete="placesDG_creationCompleteHandler(event)">

               

              </code>

               

              Got a warning Data binding will not be able to detect assignments to "placesList".

               

               

              At selection right now, assigned results to placelist

               

                 placesList = getPlacesResult.lastResult;

               

               

              Now datagrid does not show anything.   Guess I dont know how to bind to a variable.

              • 4. Re: DataGrid with only one record
                Michelle5002 Community Member

                Figured out the binding issue but now when I select a record, the datagrid is not updated until the next selection and then it updates with the previous selections data

                 

                <code>

                   protected function peopleCB_changeHandler(event:IndexChangeEvent):void
                   {
                   if (personDto.id > 0)
                   {
                   getPlacesResult.token = sampleBean.getPlaces(personDto.id);
                   placesList = getPlacesResult.lastResult;
                   placesDG.invalidateDisplayList();
                   }
                   }
                   </code>
                • 5. Re: DataGrid with only one record
                  Michelle5002 Community Member

                  Got the datagrid updating properly with a callresponder event.    Now all I need to figure out is how to determine if the result is only one record or a list of records.

                   

                      <s:CallResponder id="getPlacesResult" result="getPlacesResult_resultHandler(event)"/>