Aug 15, 2012, 8:43 PM
[CLOSED] Getting the count of the records in the Grid after calling the store.LoadProxy();
This is my previous post below:
http://forums.ext.net/showthread.php?20029-CLOSED-After-doing-a-Store1-DataBind()-how-could-I-find-the-count-of-how-many-items-are-in-the-Store&p=87352#post87352
.aspx
GetHandler.ashx.cs
http://forums.ext.net/showthread.php?20029-CLOSED-After-doing-a-Store1-DataBind()-how-could-I-find-the-count-of-how-many-items-are-in-the-Store&p=87352#post87352
.aspx
<%@ Page Language="C#" %>
<%@ 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>
<script language="javascript" type="text/javascript">
JFunction fn = new JFunction()
{
Handler = "alert(records.length);",
Args = new string[] { "records", "operation", "success" }
};
Store store = this.GridPanel1.GetStore();
store.LoadProxy(new
{
callback = fn
});
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager runat="server" />
<h1>
GridPanel with HtppHandler - Ext.NET Examples</h1>
<br />
<ext:GridPanel ID="GridPanel1" runat="server" Title="Employees" Frame="true" Height="200"
Width="600">
<Store>
<ext:Store ID="Store1" runat="server">
<Proxy>
<ext:AjaxProxy Url="../Handlers/GetHandler.ashx">
<ActionMethods Read="GET" />
<Reader>
<ext:JsonReader Root="Data" TotalProperty="TotalRecords" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Common" />
<ext:ModelField Name="Botanical" />
<ext:ModelField Name="Light" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Common Name" DataIndex="Common" Sortable="true"
Flex="1" />
<ext:Column runat="server" Text="Botanical" DataIndex="Botanical" Width="200" />
<ext:Column runat="server" Text="Light" DataIndex="Light" Width="100" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>
GetHandler.ashx.cs
using System.Collections.Generic;
using System.Web;
using Ext.Net;
namespace Web.Handlers
{
public class GetHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Write(JSON.Serialize(Plant.TestData));
}
public bool IsReusable
{
get { return false; }
}
public class Plant
{
public Plant(string light, string botanical, string common)
{
Light = light;
Botanical = botanical;
Common = common;
}
public Plant() { }
public string Common { get; set; }
public string Botanical { get; set; }
public string Light { get; set; }
public static List<Plant> TestData
{
get
{
var items = new List<Plant>();
var plant1 = new Plant { Common = "Bloodroot", Botanical = "Sanguinaria canadensis", Light = "Mostly Shady"};
items.Add(plant1);
var plant2 = new Plant { Common = "Marsh Marigold", Botanical = "Caltha palustris", Light = "Mostly Sunny" };
items.Add(plant2);
var plant3 = new Plant { Common = "Cowslip", Botanical = "Sanguinaria canadensis", Light = "Sun or Shade" };
items.Add(plant3);
return items;
}
}
}
}
}
Last edited by Daniil; Aug 16, 2012 at 5:09 PM.
Reason: [CLOSED]