9 Replies Latest reply on Aug 27, 2007 11:00 PM by chris.huston.t10

    Data Not Showing

    david_mh
      Hello all,

      I just bought and started designing with Flex 2. I'm plugging away, except I've run into a problem with my data not showing on the data grid.

      I use a combo box, with the onchange event, to resubmit the required parameters. Which succeed in querying the data, because I can tell the change of the data amount because of the scroll bar on the side of the data grid. But, for some reason, the data is not showing.

      Before I start posting code, is this a simple beginner’s oversight that the regulars here might have experienced?

      Thanks,
        • 1. Re: Data Not Showing
          chris.huston.t10 Level 3
          Hard to say exactly without code, but it sounds like the dataField and the returned data do not match up. You need to make sure that the dataField setting matches the returned data exactly, including case sensitivity.

          Vygo
          • 2. Re: Data Not Showing
            david_mh Level 1
            Thanks Masamune

            I'll take a look at my spelling and case sensitivity once again to double check. I kept thinking that that would have been the issue...

            If I can't resolve still, I will post my code.

            Regards,
            Dave
            • 3. Data Not Showing
              david_mh Level 1
              Ok, no luck with that suggestion. The field/data names are correct. So here comes the code. I've included the web service I am also calling.

              Webservice - Mover.cfc
              <cfcomponent>
              <cffunction name="listMovers" access="remote" returntype="query"
              output="yes">
              <cfargument name="unit"
              type="string"
              required="yes">
              <cfquery name="getMovers" datasource="MSSQL01">
              SELECT document_number, last_name
              FROM tbl_movers
              WHERE office_unit = #unit#
              </cfquery>
              <cfreturn getMovers>
              </cffunction>
              </cfcomponent>

              application.mxml
              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
              layout="absolute"
              creationComplete="wsMoveraggr.listMovers.send()" >

              <mx:WebService id="wsMoveraggr"
              wsdl=" http://127.0.0.1:8500/TestWebService/mover.cfc?wsdl"
              useProxy="false">
              <mx:operation name="listMovers">
              <mx:request>
              <unit>{cbxNumPosts.value}</unit>
              </mx:request>
              </mx:operation>
              </mx:WebService>

              <mx:Panel x="10" y="10" width="675" height="400" layout="absolute" title="list of Movers">
              <mx:ComboBox x="22" y="21" id="cbxNumPosts"
              change="wsMoveraggr.listMovers.send()">
              <mx:Object label="Select 125" data="125"/>
              <mx:Object label="Select 151" data="151"/>
              <mx:Object label="Select 175" data="175"/>
              </mx:ComboBox>

              <mx:DataGrid x="22" y="51" id="moverDataGrid" width="500" dataProvider="{wsMoveraggr.listMovers.lastResult}">
              <mx:columns>
              <mx:DataGridColumn
              headerText="document_number" dataField="document_number"/>
              <mx:DataGridColumn headerText="last_name" dataField="last_name"/>
              </mx:columns>
              </mx:DataGrid>
              <mx:Button x="36" y="215" label="Button" click="wsMoveraggr.listMovers.send()"/>
              </mx:Panel>

              </mx:Application>
              • 4. Re: Data Not Showing
                david_mh Level 1
                I don't know how busy/fast these forums are, so I'll re-ask for a responce.
                • 5. Re: Data Not Showing
                  chris.huston.t10 Level 3
                  Sorry for the slow reply. I live in Japan so there is probably a bit of a time difference. It is quite difficult to debug WebService calls when you bind the result using lastResult. A better approach is to use a result event function in which you can check the values directly.

                  <mx:WebService id="wsMoveraggr"
                  wsdl=" http://127.0.0.1:8500/TestWebService/mover.cfc?wsdl"
                  useProxy="false"
                  result="listMoverResult(event)>

                  Then in AS:

                  private function listMoverResult(evt:ResultEvent):void {
                  moverDataGrid.dataProvider = evt.result;
                  trace(evt.result);
                  }

                  You can now debug the WebService result by looking at the values returned to make sure they match your dataGrid settings. It can be helpful to put a break point in the result event function so you can see the values more easily. This should help you find your problem.

                  Vygo
                  • 6. Re: Data Not Showing
                    david_mh Level 1
                    That was the ideal reply. Thank you so much!

                    I will report back with my findings.
                    • 7. Data Not Showing
                      david_mh Level 1
                      Edit..figuring this out, and posting before I tried hard enough. :)
                      • 8. Re: Data Not Showing
                        david_mh Level 1
                        Im not declairing the below method, but dont know where I'm supposed to do. Below is the error msg I'm getting. I'm gonna consult with the guys at work, then post again.

                        1180: Call to a possibly undefined method listMoverResult.
                        • 9. Re: Data Not Showing
                          chris.huston.t10 Level 3
                          David,

                          When you set the result="someFunctionName(event)", you need to define this function in ActionScript like this:

                          <mx:Script><![CDATA[
                          import mx.rpc.events.ResultEvent;
                          private function listMoverResult(evt:ResultEvent):void {
                          moverDataGrid.dataProvider = evt.result;
                          trace(evt.result);
                          }
                          ]]></mx:Script>

                          You can place all your ActionScript functions within the script tags. It is hard to build too much without using some ActionScript. Make sure you choose to debug the application, not run it. You can only see the results from the trace() function in debug mode.

                          Vygo