Paging and Sorting

  1. #1

    Paging and Sorting

    Hi,


    I'm creating a GridPanel where I need to implent the Paging Sort. I followed that example (https://examples1.ext.net/#/GridPane...rting/Handler/) and I implemented with DataBase (625 rows), but isn't work. During execute "context.Response.Write(JSON.Serialize(pageCliente ));" occurs a error.
    Image with error message attached!

    Grid.Aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>GridPanel with HtppHandler - Ext.NET Examples</title>
        
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                Title="Employees" 
                Frame="true" 
                AutoExpandColumn="ClnRazaoSocial" 
                Height="300">
                <Store>
                    <ext:Store ID="Store1" runat="server" RemoteSort="true">
                        <Proxy>
                            <ext:HttpProxy Method="GET" Url="PlantHandler.ashx" />
                        </Proxy>
                        <AutoLoadParams>
                            <ext:Parameter Name="start" Value="={0}" />
                            <ext:Parameter Name="limit" Value="={10}" />
                        </AutoLoadParams>
                        <Reader>
                            <ext:JsonReader Root="Data" TotalProperty="TotalRecords">
                                <Fields>
                                    <ext:RecordField Name="ClnRazaoSocial" />
    
    
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                        <SortInfo Field="ClnRazaoSocial" Direction="ASC" />
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ColumnID="ClnRazaoSocial" Header="Descricão" DataIndex="ClnRazaoSocial" Width="220" Sortable="true" />
                        
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                </SelectionModel>            
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" 
                        runat="server" 
                        PageSize="10"
                        DisplayInfo="true" 
                        DisplayMsg="Displaying plants {0} - {1} of {2}" 
                        EmptyMsg="No plants to display" 
                        />
                </BottomBar>
                <LoadMask ShowMask="true" />
            </ext:GridPanel>
        </form>
    </body>
    </html>
    PlantHandler
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Ext.Net;
    using BmaSuite.Dominio.Entidade.Crm;
    using BmaSuite.Dominio.Servico.Crm;
    using BmaSuite.Repositorio.NHibernate.Repositorio.Crm;
    using Ext.Net;
    using System.Collections;
    using System.Web.Services;
    
    
    namespace WebApplication1
    {
        /// <summary>
        /// Summary description for PlantHandler
        /// </summary>
        /// 
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        public class PlantHandler : IHttpHandler
        {
            private readonly ClienteSer _clienteServico = new ClienteSer(new ClienteRep());       
            
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "application/json";
    
    
                var start = 0;
                var limit = 10;
                var sort = string.Empty;
                var dir = string.Empty;
                var query = string.Empty;
                var filter = string.Empty;
    
    
                if (!string.IsNullOrEmpty(context.Request["start"]))
                {
                    start = int.Parse(context.Request["start"]);
                }
    
    
                if (!string.IsNullOrEmpty(context.Request["limit"]))
                {
                    limit = int.Parse(context.Request["limit"]);
                }
    
    
                if (!string.IsNullOrEmpty(context.Request["sort"]))
                {
                    sort = context.Request["sort"];
                }
    
    
                if (!string.IsNullOrEmpty(context.Request["dir"]))
                {
                    dir = context.Request["dir"];
                }
                List<Cliente> c = _clienteServico.RetornarTodos(1).ToList();
                if (!string.IsNullOrEmpty(sort))
                {
                    c.Sort(delegate(Cliente x, Cliente 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) > c.Count)
                {
                    limit = c.Count - start;
                }
    
    
                List<Cliente> rangeCliente = (start < 0 || limit < 0) ? c : c.GetRange(start, limit);
                Paging<Cliente> pageCliente = new Paging<Cliente>(rangeCliente, c.Count);
                context.Response.Write(JSON.Serialize(pageCliente));        
            }
    
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
    Class Cliente
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using BmaSuite.Dominio.Entidade.Menu;
    
    
    namespace BmaSuite.Dominio.Entidade.Crm
    {
        
        public partial class Cliente  
    
    
        {
            public virtual int ClnId { get; set; }
            public virtual Empresa EmpId { get; set; }
            public virtual string ClnRazaoSocial { get; set; }
            public virtual string ClnApelido { get; set; }
            public virtual string ClnEndereco { get; set; }
            public virtual string ClnNumero { get; set; }
            public virtual string ClnComplementoEnd { get; set; }
            public virtual string ClnBairro { get; set; }
            public virtual string ClnCep { get; set; }
            public virtual string ClnCidade { get; set; }
            public virtual string ClnEstado { get; set; }
            public virtual DateTime ClnDataCadastro { get; set; }
            public virtual string ClnFone { get; set; }
            public virtual string ClnFone1 { get; set; }        
            public virtual Representante RprId { get; set; }
            public virtual Usuario UsrId { get; set; }    
            public virtual Midia MdaId { get; set; }        
            public virtual string ClnComplementoMidia { get; set; }
            public virtual Concorrente CcrId { get; set; }
            public virtual string ClnComplementoConcorrente { get; set; }
            public virtual string ClnObservacao { get; set; }
            public virtual int ClnStatus { get; set; }
            public virtual string ClnTipoInscricao { get; set; }
            public virtual string ClnNumeroInscricao { get; set; }        
            public virtual string ClnSite { get; set; }
            public virtual AreaInteresse AriId { get; set; }
            public virtual string ClnComplementoAreaInteresse { get; set; }
            public virtual Situacao StcId { get; set; }
            public virtual DateTime ClnDataUltimoContato { get; set; }
            public virtual IList<ClientePessoaContato> ClientePessoaContato { get; set; }
            public virtual IList<ClienteContatoRealizado> ClienteContatoRealizado { get; set; }
            public virtual IList<ClienteProduto> ClienteProduto { get; set; }
            public virtual IList<ClienteProjeto> ClienteProjeto { get; set; }    
            
            public Cliente()
            {
                EmpId = new Empresa();
                RprId = new Representante();            
                MdaId = new Midia();
                CcrId = new Concorrente();            
                AriId = new AreaInteresse();
                StcId = new Situacao();
                UsrId = new Usuario();
                ClnStatus = (int)ClienteStatusEnum.Prospect;
            }
           
        }
    }


    Thankful for attention!
    Maia
    Ext.Net 1.1
    Attached Thumbnails Click image for larger version. 

Name:	error.jpg 
Views:	85 
Size:	98.9 KB 
ID:	3184   Click image for larger version. 

Name:	error2.jpg 
Views:	55 
Size:	102.4 KB 
ID:	3191  
    Last edited by Maia; Sep 14, 2011 at 11:12 PM.
  2. #2
    Hi,
    I did some tests and I checked that works up to 30 records, but if I send load over 30 records occurs the same error where I commented above.
    Any tips what can be?

    Thankful for attention!
    Maia
    Ext.Net 1.1
  3. #3
    It means that your records contain many information (occupies big amount of memory)
    For example, I see that your class has several collections and references on other classes
    Try to create simple class which contains required properties only (properties are expected by store) because it is not good to pass to the client needless information

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. Find record with remote paging and sorting
    By schrovena in forum 1.x Help
    Replies: 1
    Last Post: Apr 26, 2011, 6:00 PM
  3. GridPanel Auto Paging and Sorting
    By Dominik in forum 1.x Help
    Replies: 2
    Last Post: May 17, 2010, 9:24 AM
  4. Paging and Sorting Example throws exception
    By Skorfulose in forum 1.x Help
    Replies: 1
    Last Post: Nov 19, 2009, 3:30 AM
  5. Replies: 2
    Last Post: Nov 17, 2009, 1:26 PM

Posting Permissions