PDA

View Full Version : [CLOSED] GridPanel - Infinite scroll not working



Arohan
Feb 25, 2014, 1:58 PM
I am using Ext.Net Version 2.4.0.30073 and exploring through Firefox.

We have written an AjaxProxy to get the records on demand from Buffered Store.

I have given below the code which does not work properly as expected for Infinite Scroll. It shows records on first page and does not give call on demand as expected for Infinite scrolling.

Deault.aspx Code:




<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Forms_InfiniteScroll_Default" %>

<!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 runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager runat="server" />
<form id="form1" runat="server">
<ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
<Items>
<ext:GridPanel ID="SalaryGridPanel" runat="server" Frame="true" Height="300" Layout="FitLayout"
Region="Center">
<Store>
<ext:Store runat="server" ID="SalaryStore" Bufferd="true" PageSize="100" ShowWarningOnFailure="false">
<Model>
<ext:Model ID="SalaryModel" runat="server" Name="Salary" IDProperty="_IDkey">
<Fields>
<ext:ModelField Name="_IDKey" Type="Int" />
<ext:ModelField Name="EmpNo" Type="String" />
<ext:ModelField Name="EDCode" Type="String" />
<ext:ModelField Name="Amount" Type="Float" />
</Fields>
</ext:Model>
</Model>

<Proxy>
<ext:AjaxProxy Url="SalaryList.ashx">
<Reader>
<ext:JsonReader Root="data" SuccessProperty="success" MessageProperty="message" TotalProperty="total" />
</Reader>
</ext:AjaxProxy>
</Proxy>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="cEmpNo" runat="server" Text="EmpNo" DataIndex="EmpNo">
<Editor>
<ext:TextField ID="txtEmpNo" runat="server" MaxLength="10" AllowBlank="false">
</ext:TextField>
</Editor>
</ext:Column>
<ext:Column ID="cEDCode" runat="server" Text="EDCode" DataIndex="EDCode">
<Editor>
<ext:TextField ID="txtEDCode" runat="server" MaxLength="3" AllowBlank="false">
</ext:TextField>
</Editor>
</ext:Column>
<ext:NumberColumn ID="ncAmount" runat="server" Text="Amount" DataIndex="Amount">
<Editor>
<ext:NumberField ID="NumAmount" runat="server" AllowBlank="false" SpinUpEnabled="false"
SpinDownEnabled="false" HideTrigger="true" MinValue="0" FieldStyle="text-align: right">
</ext:NumberField>
</Editor>
</ext:NumberColumn>
</Columns>
</ColumnModel>
<%--<Features>
<ext:GridFilters runat="server" ID="SalaryGridFilters" Local="true">
<Filters>
<ext:StringFilter DataIndex="EmpNo" />
<ext:StringFilter DataIndex="EDCode" />
<ext:NumericFilter DataIndex="Amount" />
</Filters>
</ext:GridFilters>
</Features>--%>
<View>
<ext:GridView ID="SalaryGridView" runat="server" TrackOver="false" />
</View>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single" />
</SelectionModel>
</ext:GridPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>



Default.aspx.cs



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;

public partial class Forms_InfiniteScroll_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Show();
}
}

public void Show()
{
SalaryStore.Reload();
}
}


SalaryList.ashx:



<%@ WebHandler Language="C#" Class="SalaryList" %>

using System;
using System.Web;
using System.Data;

using Ext.Net;

public class SalaryList : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
StoreResponseData sr = new StoreResponseData();
string action = context.Request["action"];

try
{
if (string.IsNullOrEmpty(action) || Store.Action(action) == StoreAction.Read)
{
this.ReturnData(context);
return;
}


}
catch (Exception e)
{
sr.Success = false;
sr.Message = e.Message;
sr.Return();
}
//sr.Return();
}

public bool IsReusable
{
get
{
return false;
}
}

private void ReturnData(HttpContext context)
{
var requestParams = new StoreRequestParameters(context);
int Page = requestParams.Page;
int PageSize = requestParams.Limit;

StoreResponseData sr = new StoreResponseData();
DataTable dt = PrepareData(PageSize, Page);
sr.Data = JSON.Serialize(dt);
sr.Total = 10000;
sr.Return();
}

private DataTable PrepareData(int PageSize, int Page)
{
DataTable dt = CreateDataTable();
DataRow dr;
for (int i = (((Page-1) * PageSize) +1); i <= Page * PageSize; i++)
{
dr = dt.NewRow();
dr["_IDKey"] = i;
dr["Amount"] = i;
dr["EmpNo"] = i.ToString();
dr["EDCode"] = i.ToString();

dt.Rows.Add(dr);
}
return dt;


}

public static DataTable CreateDataTable()
{
DataTable dt = new DataTable("Table");
dt.Locale = System.Threading.Thread.CurrentThread.CurrentCultu re;
DataColumn dc = null;

//Employee Code
dc = new DataColumn();
dc.ColumnName = "_IDKey";
dc.DataType = System.Type.GetType("System.Int32");
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = "Amount";
dc.DataType = System.Type.GetType("System.Int32");
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = "EmpNo";
dc.DataType = System.Type.GetType("System.String");
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = "EDCode";
dc.DataType = System.Type.GetType("System.String");
dt.Columns.Add(dc);



return dt;
}


}



Amazingly there is no error in Firebug and in code-behind also.

Please help.

Daniil
Feb 25, 2014, 5:04 PM
Hi @Arohan,

Please replace

Bufferd="true"
with

Buffered="true"

Arohan
Feb 26, 2014, 4:26 AM
Daniil, Thanks for pin pointing the mistake we made. Sorry for wasting your time. Please mark it as solved.