[CLOSED] Getting the count of the records in the Grid after calling the store.LoadProxy();

  1. #1

    [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
    <%@ 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]
  2. #2
    Hi,

    It looks to be C# code, not JavaScript.

    Quote Originally Posted by Fahd View Post
    <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>
    Also the problem is unclear. Please provide more details.
    Last edited by Daniil; Aug 16, 2012 at 6:49 AM.
  3. #3
    I have updated my sample, but I can't get the Javascript funtion to fire.

    I expect it to fire my Javascript function, 'NoOfRecords' showing my the # of records.

    When I click the Button, "Load Proxy"

    works
    Handler = "alert(records.length);"
    does NOT work
      Fn = "NoOfRecords(records.length);",
    .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 runat="server">
    
            protected void Page_Load(object sender, EventArgs e)
            {
                Store1.Proxy.Add(new AjaxProxy
                {
                    NoCache = true,
                    Json = true,
                    ActionMethods = { Read = HttpMethod.GET },
                    Reader = { new JsonReader { Root = "Data", TotalProperty = "TotalRecords" } },
                    Url = "../Handlers/GetHandler.ashx"
                });
            }
    
            [DirectMethod]
            public void LoadProxy(object sender, DirectEventArgs e)
            {
                var fn = new JFunction()
                {
                    //Handler = "alert(records.length);",
                    Fn = "NoOfRecords(records.length);",
                    Args = new [] { "records", "operation", "success" }
                };
                
                var store = GridPanel1.GetStore();
                store.LoadProxy(new
                {
                    callback = fn
                }); 
            }
    
        </script>
    
        <script language="javascript" type="text/javascript">
    
            var NoOfRecords = function(length){
                debugger;
                Ext.Msg.notify("Number of Records", "Rows: " + length);
            }
        
        </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" AutoDataBind="false" AutoLoad="false">
                    <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>
        <br />
        <ext:Button ID="Button1" runat="server" Text="Call Proxy" OnDirectClick="LoadProxy" />
        </form>
    </body>
    </html>
    Quote Originally Posted by Daniil View Post
    Hi,

    It looks to be C# code, not JavaScript.



    Also the problem is unclear. Please provide more details.
  4. #4
    Fn expects a function name or a full function definition.
    Fn="someFunctionName"
    or
    Fn="function () { alert('Hello!'); }"
  5. #5
    Got it. thanks...

    Quote Originally Posted by Daniil View Post
    Fn expects a function name or a full function definition.
    Fn="someFunctionName"
    or
    Fn="function () { alert('Hello!'); }"

Similar Threads

  1. Replies: 1
    Last Post: Dec 22, 2011, 6:17 AM
  2. [CLOSED] Identify new and unaltered grid rows/store records
    By GLD in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Oct 06, 2011, 11:25 AM
  3. Replies: 1
    Last Post: Nov 01, 2010, 9:00 PM
  4. [CLOSED] [1.0] Paged grid displays all records on store's reload
    By danielg in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 25, 2010, 11:26 AM
  5. Replies: 1
    Last Post: Oct 27, 2009, 10:39 AM

Tags for this Thread

Posting Permissions