Objective:  To show a predefined number of records from the database 
and  Populate a datagride.Say there are 50 records in the database 
and the requirement is to show 10 at time. 
MXML:

Mxml  file

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; xmlns="*" 
pageTitle="Contact Manager" creationComplete="initApp()">
<mx:Script>
    <![CDATA[
             import samples.contact.*;
              [Bindable]
             public var contacts:ArrayCollection;
             [Bindable]
             public var contact:Contact;
             private var ds:DataService; 
private function initApp():void
        {
            var i:int;
            contacts = new ArrayCollection();
            ds = new DataService("contact");
            ds.pageSize=4;
            ds.autoCommit = false;
            ds.fill(contacts);
           AsyncToken(ds.fill(contacts));
            token.kind = "fill";
          }
  ]]>
    </mx:Script>

<mx:DataGrid id="dg" 
dataProvider="{contacts}"                                            
                  width="100%" height="100%" change="contact=Contact
(dg.selectedItem)" editable="true"  >
     <mx:columns>
                    <mx:DataGridColumn  
dataField="contactId"                               headerText="Id"/>
                    <mx:DataGridColumn dataField="firstName" 
headerText="First Name"/>
                    <mx:DataGridColumn dataField="lastName" 
headerText="Last Name"/>
       </mx:columns>
</mx:DataGrid>



Flex-data-service.xml:
-----------------------


<destination id="contact">

        <adapter ref="java-dao" />

        <properties>
            <source>samples.contact.ContactAssembler</source>
            <scope>request</scope>

            <metadata>
                <identity property="contactId"/>
            </metadata>

            <network>
                <session-timeout>2</session-timeout>
                <paging enabled="true" pageSize="10"/>
                <throttle-inbound policy="ERROR" max-
frequency="500"/>
                <throttle-outbound policy="REPLACE" max-
frequency="500"/>
            </network>

            <server>
                <fill-method>
                    <name>loadContacts</name>
                </fill-method>

                <fill-method>
                    <name>loadContacts</name>
                    <params>java.lang.String</params>
                </fill-method>

                <sync-method>
                    <name>syncContacts</name>
                </sync-method>
            </server>
        </properties>
    </destination>


Result: The above code always returns all the rows from database.  

Question is: From data-grid is there any way to point to the java 
adapater without using the Actionscript where data service 
automatically uses the flex config.xml and fetches the data 
accordingly?  







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to