[CLOSED] Jump to grid row with paging

  1. #1

    [CLOSED] Jump to grid row with paging

    Hi Guys

    Ignoring the callback can the below be implemented server side as I do not see a method on the store for FindPage

    
            var selectRecord = function (id) {
                var grid = App.GridPanel1,
                    record = grid.store.getById(id);
                
                grid.store.loadPage(grid.store.findPage(record), {
                    callback : function () {
                        grid.getSelectionModel().select(record);
                    }
                });            
            };
    Basically I want to jump to a page and select a row (i know the id) on a just loaded grid where that row could exist on a page other than the first one. I could implement this post load client side but would rather not.

    Thanks,
    D
    Last edited by Daniil; Jan 20, 2014 at 10:50 AM. Reason: [CLOSED]
  2. #2
    Hi @CanopiusApplications,

    A Store's findPage JavaScript method deals with a Store's client side properties which cannot be accessed on server.

    You can determine a page manually and call loadPage inside a GridPanel's AfterRender listener.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test1" },
                    new object[] { "test2" },
                    new object[] { "test3" },
                    new object[] { "test4" },
                    new object[] { "test5" },
                    new object[] { "test6" },
                    new object[] { "test7" },
                    new object[] { "test8" },
                    new object[] { "test9" }
                };
    
                string recordId = "test5";
                int page = 2; // you should determine it by yourself according to "recordId"
    
                this.GridPanel1.Listeners.AfterRender.Handler = string.Format("this.getStore().loadPage({0});", page); 
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store runat="server" PageSize="3">
                        <Model>
                            <ext:Model runat="server" IDProperty="test">
                                <Fields>
                                    <ext:ModelField Name="test" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test" DataIndex="test" />
                    </Columns>
                </ColumnModel>
                <BottomBar>
                    <ext:PagingToolbar runat="server" />
                </BottomBar>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3
    Thanks D I kind of figured that would be the case reading some of the other posts.

    Quote Originally Posted by Daniil View Post
    Hi @CanopiusApplications,

    A Store's findPage JavaScript method deals with a Store's client side properties which cannot be accessed on server.

    You can determine a page manually and call loadPage inside a GridPanel's AfterRender listener.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test1" },
                    new object[] { "test2" },
                    new object[] { "test3" },
                    new object[] { "test4" },
                    new object[] { "test5" },
                    new object[] { "test6" },
                    new object[] { "test7" },
                    new object[] { "test8" },
                    new object[] { "test9" }
                };
    
                string recordId = "test5";
                int page = 2; // you should determine it by yourself according to "recordId"
    
                this.GridPanel1.Listeners.AfterRender.Handler = string.Format("this.getStore().loadPage({0});", page); 
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store runat="server" PageSize="3">
                        <Model>
                            <ext:Model runat="server" IDProperty="test">
                                <Fields>
                                    <ext:ModelField Name="test" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test" DataIndex="test" />
                    </Columns>
                </ColumnModel>
                <BottomBar>
                    <ext:PagingToolbar runat="server" />
                </BottomBar>
            </ext:GridPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 11
    Last Post: Jun 13, 2012, 4:53 PM
  2. Replies: 0
    Last Post: May 24, 2012, 7:39 AM
  3. How do press Enter key jump like Tab?
    By whs2893 in forum 1.x Help
    Replies: 6
    Last Post: Mar 23, 2011, 3:07 AM
  4. Replies: 1
    Last Post: Mar 09, 2010, 2:27 PM
  5. [CLOSED] How to jump to selected record when GridPanel reloads?
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 10, 2009, 11:55 AM

Posting Permissions