2 Replies Latest reply on Oct 13, 2010 4:15 AM by meerajk

    Datagrid with http xml service




      I am populating a datagrid with HTTP service that is returning XML. The declaration of the HTTP service is as follows,


              <mx:HTTPService id="banks" url="services/banks" useProxy="false" method="GET" showBusyCursor="true">
                  <mx:request xmlns="">


      And the data grid is defined like below,


              <mx:DataGrid id="bankGrid" width="100%" height="45%" dataProvider="{banks.lastResult.banks.bank}" itemClick="listBankSchemes()">
                      <mx:DataGridColumn dataField="bankId" headerText="Bank Id"/>
                      <mx:DataGridColumn dataField="bankName" headerText="Bank Name"/> 


      I have two issues ..


      1. The bankId column is behaving strangely. When the back-end sends the value 12345678901234567, it datagrid displays 12345678901234568. Similarly when the back-end sends 1234567890123456790, the grid displays 12345678901234567000. I am totally perplexed with this behaviour. Once the data is displayed, even if I get the cell value for a selected row, I get the wrong value to what came back from the back-end.


      2. If the bankId is an arbitrarily large value, the datagrid displays the data in scientific notation, even though the cell is expected to display text data containing numeric literals.


      Any help or pointers on these will be highly appreciated.


      Kind regards


        • 1. Re: Datagrid with http xml service
          BhaskerChari Level 4

          Hi Meeraj,


          You need to send in the numeric values as the string instead of numeric values...These values will be automatically converted to different value due to type conversion and as the  bankId is an arbitrarily large value.


          While you are trying to generate the xml you send it as string instead of numeric value.


          I mean something like below...If you notice below correctly I have enclosed the numeric in single quotes so that it is treated as string when you assign it to datagrid in Flex. Dont forget to remove the single quotes while binding to datagrid column.







          • 2. Re: Datagrid with http xml service
            meerajk Level 1



            Thanks for your reply. My problem was caused by the data provider for the grid refererring to incorrect XML path expression. On your answer though, in the absence of a constraining grammar (like XSD), there is no implicit type information available in instance documents. Just because the element content is made of numeric literals doesn't imply the content is a number.


            I think the result type on the HTTP service influences how the runtime deduce type information from the underlying XML. Does, anyone know how the runtime decides the type of a value bound to a cell within the datagrid from the data sourced through the HTTP service?


            Kind regards