[CLOSED] Example for Paging in Grid with WebService-Content as DataSource

  1. #1

    [CLOSED] Example for Paging in Grid with WebService-Content as DataSource

    Hello,

    does anybody have a working example which shows paging in a grid which uses an xml-webservice as source?



    Regards,

    Martin
  2. #2

    RE: [CLOSED] Example for Paging in Grid with WebService-Content as DataSource

    Hi,

    WebService (Plant class see in source code of https://examples1.ext.net/#/Form/Com...Custom_Search/)
    [WebMethod]
            public Paging<Plant> PlantsPaging(int start, int limit, string sort, string dir, string filter)
            {
                List<Plant> plants = Plant.TestData;
                if (!string.IsNullOrEmpty(filter) &amp;&amp; filter != "*")
                {
                    plants.RemoveAll(plant => !plant.Common.ToLower().Contains(filter.ToLower()));
                }
    
                if (!string.IsNullOrEmpty(sort))
                {
                    plants.Sort(delegate(Plant x, Plant y)
                    {
                        object a;
                        object b;
    
                        int direction = dir == "DESC" ? -1 : 1;
    
                        a = x.GetType().GetProperty(sort).GetValue(x,null);
                        b = y.GetType().GetProperty(sort).GetValue(y, null);
    
                        return CaseInsensitiveComparer.Default.Compare(a, b) * direction;
                    });
                }
    
                if ((start + limit) > plants.Count)
                {
                    limit = plants.Count - start;
                }
    
                List<Plant> rangePlants = (start < 0 || limit < 0) ? plants : plants.GetRange(start, limit);
    
                return new Paging<Plant>(rangePlants, plants.Count);
            }

    Store to read data from web service
     <ext:Store ID="Store1" runat="server" RemoteSort="true">
                <Proxy>
                    <ext:HttpProxy Method="GET" Url="../../Shared/PlantService.asmx/PlantsPaging" />
                </Proxy>
                <AutoLoadParams>
                    <ext:Parameter Name="start" Value="={0}" />
                    <ext:Parameter Name="limit" Value="={5}" />
                </AutoLoadParams>
                <BaseParams>
                    <ext:Parameter Name="filter" Value="" Mode="Value"></ext:Parameter>
                </BaseParams>
                <Reader>
                    <ext:XmlReader Record="Plant" TotalRecords="TotalRecords" >
                        <Fields>
                            <ext:RecordField Name="Common" />
                            <ext:RecordField Name="Botanical" />
                            <ext:RecordField Name="Light" />
                            <ext:RecordField Name="Price" Type="Float" />
                            <ext:RecordField Name="Availability" Type="Date" />
                            <ext:RecordField Name="Indoor" Type="Boolean" />
                        </Fields>
                    </ext:XmlReader>
                </Reader>
                <SortInfo Field="Common" Direction="ASC" />
            </ext:Store>

Similar Threads

  1. Replies: 11
    Last Post: Jun 13, 2012, 4:53 PM
  2. Replies: 2
    Last Post: Apr 11, 2012, 11:10 AM
  3. Replies: 2
    Last Post: Oct 28, 2011, 6:44 AM
  4. [CLOSED] [1.0] Store of WebService HttpProxy with DataTable Paging
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Sep 13, 2010, 8:58 AM
  5. Replies: 1
    Last Post: Jul 23, 2010, 10:02 PM

Posting Permissions