Paging and sorting Page example not working

  1. #1

    Paging and sorting Page example not working

    This https://examples2.ext.net/#/GridPane..._Sorting/Page/ example is not working when I try to use in my source.

    My Source Code is below:

    In aspx page I have writte



    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PagingIngridview.aspx.cs" Inherits="SampleExample.PagingIngridview" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style>
            .x-grid-td-fullName .x-grid-cell-inner {
                font-family: tahoma, verdana;
                display: block;
                font-weight: normal;
                font-style: normal;
                color: #385F95;
                white-space: normal;
            }
    
            .x-grid-rowbody p {
                margin: 5px 5px 10px 5px !important;
                width: 99%;
                color: Gray;
                font-size: 11px !important;
                line-height: 13px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
            <asp:ObjectDataSource
                ID="ObjectDataSource1"
                runat="server"
                OnSelecting="EmployeeSelecting"
                OnSelected="ObjectDataSource1_Selected"
                SelectMethod="GetEmployeesFilter"
                TypeName="SampleExample.InventoryCls">
                <SelectParameters>
                    <asp:Parameter Name="start" Type="Int32" />
                    <asp:Parameter Name="limit" Type="Int32" />
                    <asp:Parameter Name="sort" Type="Object" />
                    <asp:Parameter Name="count" Direction="Output" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
    
            <ext:GridPanel
                runat="server"
                ID="GridPanel1"
                Title="Employees"
                Frame="true"
                Height="300">
                <Store>
                    <ext:Store
                        ID="Store1"
                        runat="server"
                        RemoteSort="true"
                        DataSourceID="ObjectDataSource1"
                        OnReadData="Store1_RefreshData"
                        PageSize="3">
                        <Proxy>
                            <ext:PageProxy />
                        </Proxy>
                        <Model>
                            <ext:Model ID="Model1" runat="server" IDProperty="InventoryID">
                                <Fields>
                                    <ext:ModelField Name="SKU" />
                                    <ext:ModelField Name="Quntity" />
                                    <ext:ModelField Name="Cost" />
                                    <ext:ModelField Name="Price" />
                                    <ext:ModelField Name="Weight" />
                                   
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Sorters>
                            <ext:DataSorter Property="LastName" Direction="ASC" />
                        </Sorters>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ID="Column1" runat="server" Text="Full Name" Width="150" DataIndex="LastName">
                            <Renderer Fn="fullName" />
                        </ext:Column>
                        <ext:Column ID="Column2" runat="server" DataIndex="SKU" Text="SKU" Width="150" />
                        <ext:Column ID="Column3" runat="server" DataIndex="Quntity" Text="Quntity" Width="150" />
                        <ext:Column ID="Column6" runat="server" DataIndex="Cost" Text="Cost" Width="110"  />
                        <ext:Column ID="Column7" runat="server" DataIndex="Price" Text="Price" Width="110"  />
                        <ext:Column ID="Column4" runat="server" DataIndex="Weight" Text="Weight" Width="150" />
                        <ext:Column ID="Column5" runat="server" DataIndex="City" Text="City" Width="100" />
                        
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GridView ID="GridView1" runat="server">
                        <GetRowClass Handler="return 'x-grid-row-expanded';" />
                    </ext:GridView>
                </View>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Multi" />
                </SelectionModel>
                <Features>
                    <ext:RowBody ID="RowBody1" runat="server">
                        <GetAdditionalData
                            Handler="return {rowBodyColspan : record.fields.getCount(), rowBody : '<p>' + data.Notes + '</p>'};" />
                    </ext:RowBody>
                </Features>
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1"
                        runat="server"
                        DisplayInfo="true"
                        DisplayMsg="Displaying employees {0} - {1} of {2}"
                        EmptyMsg="No employees to display" />
                </BottomBar>
            </ext:GridPanel>
    
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>
    In aspx.cs file I have

    using Ext.Net;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace SampleExample
    {
        public partial class PagingIngridview : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            StoreReadDataEventArgs e;
            protected void Store1_RefreshData(object sender, StoreReadDataEventArgs e)
            {
                string tpl = "Start: {0}<br />Limit: {1}<br />Sort: {2}<br />Dir: {3}";
    
                this.Label1.Html = string.Format(tpl, e.Start, e.Limit, e.Sort[0].Property, e.Sort[0].Direction);
    
                //this.Label1.Text = e.Sort[0].Property + ":" + e.Sort[0].Direction.ToString();
    
                this.e = e;
    
                this.Store1.DataBind();
            }
    
            protected void EmployeeSelecting(object sender, ObjectDataSourceSelectingEventArgs e)
            {
                e.InputParameters["start"] = this.e.Start;
                e.InputParameters["limit"] = this.e.Limit;
                e.InputParameters["sort"] = this.e.Sort[0];
            }
    
            protected void ObjectDataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs e)
            {
                (this.Store1.Proxy[0] as PageProxy).Total = (int)e.OutputParameters["count"];
            }
        }
    }
    In(handler File) ashx.cs I have written following code

    using Ext.Net;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    
    namespace SampleExample
    {
        /// <summary>
        /// Summary description for PlantHandler
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        public class PlantHandler : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "application/json";
    
                StoreRequestParameters prms = new StoreRequestParameters(context);
                Paging<Plant> plants = Plant.PlantsPaging(prms.Start, prms.Limit, prms.Sort[0].Property, prms.Sort[0].Direction.ToString(), string.Empty);
    
                context.Response.Write(JSON.Serialize(plants));
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
    and class file I have wrriten following code:


    using Ext.Net;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Linq.Expressions;
    using System.Web;

    namespace SampleExample
    {
    public class InventoryCls
    {
    public static List<Inventory> GetAll()
    {
    DataClasses1DataContext db = new DataClasses1DataContext();

    return db.Inventories.ToList();
    }

    public static Inventory GetInventory(int id)
    {
    DataClasses1DataContext db = new DataClasses1DataContext();

    return GetInventory(id, db);
    }

    public static Inventory GetInventory(int id, DataClasses1DataContext db)
    {
    return db.Inventories.Single(e => e.InventoryID == id);
    }

    public static List<Inventory> GetInventoriesFilter(int start, int limit, DataSorter sort, out int count)
    {
    DataClasses1DataContext db = new DataClasses1DataContext();
    IQueryable<Inventory> result = db.Inventories.Select(e => e);

    if (sort != null)
    {
    ParameterExpression param = Expression.Parameter(typeof(Inventory), "e");


    Expression<Func<Inventory, object>> sortExpression = Expression.Lambda<Func<Inventory, object>>(Expression.Property(param, sort.Property), param);
    if (sort.Direction == SortDirection.DESC)
    {
    result = result.OrderByDescending(sortExpression);
    }
    else
    {
    result = result.OrderBy(sortExpression);
    }

    }

    if (start >= 0 && limit > 0)
    {
    result = result.Skip(start).Take(limit);
    }

    count = db.Inventories.Count();

    return result.ToList();
    }
    }
    }


    Above code is based on https://examples2.ext.net/#/GridPane..._Sorting/Page/ example.

    So please help me. what else I have to do? to work paging.
  2. #2
    Hi,

    Please wrap all the code in code tags.

Similar Threads

  1. [CLOSED] remote paging and sorting with SQL
    By marco.morreale in forum 2.x Legacy Premium Help
    Replies: 13
    Last Post: Apr 27, 2012, 4:02 PM
  2. Replies: 2
    Last Post: Dec 22, 2011, 2:45 PM
  3. Paging and Sorting
    By Maia in forum 1.x Help
    Replies: 2
    Last Post: Sep 15, 2011, 1:51 PM
  4. GridPanel Auto Paging and Sorting
    By Dominik in forum 1.x Help
    Replies: 2
    Last Post: May 17, 2010, 9:24 AM
  5. Paging and Sorting Example throws exception
    By Skorfulose in forum 1.x Help
    Replies: 1
    Last Post: Nov 19, 2009, 3:30 AM

Tags for this Thread

Posting Permissions