[CLOSED] GridPanel Paging

  1. #1

    [CLOSED] GridPanel Paging

    Hello,

    Can you provide an example of how server-side paging works with a GridPanel, or is there already an example in the sandbox I looked past?

    Cheers,
    Timothy
  2. #2

    RE: [CLOSED] GridPanel Paging

    Hi Timothy,

    Please see the following sample:


    https://examples1.ext.net/#/GridPane...g_and_Sorting/

    *

  3. #3

    RE: [CLOSED] GridPanel Paging

    Thanks vladimir,

    Can you provide an example with not having to use an ObjectDataSource but instead binding through the code behind?

    Cheers,
    Timothy
  4. #4

    RE: [CLOSED] GridPanel Paging

    Hi Timothy,

    please see the following sample
    <%@ Import Namespace="Coolite.Examples.Code.Northwind"%>
    <%@ Import Namespace="System.Collections.Generic"%>
    <%@ Import Namespace="System.Linq"%>
    <%@ Import Namespace="System.Linq.Expressions"%>
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" 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>Coolite Toolkit - GridPanel with ObjectDataSource</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    
        <script runat="server">
            public List<Employee> GetEmployeesFilter(int start, int limit, string sort, string dir, out int count)
            {
                NorthwindDataContext db = new NorthwindDataContext();
                IQueryable<Coolite.Examples.Code.Northwind.Employee> result = db.Employees.Select(e => e);
                if (!string.IsNullOrEmpty(sort))
                {
                    var param = Expression.Parameter(typeof(Employee), "e");
                    var sortExpression = Expression.Lambda<Func<Employee, object>>(Expression.Property(param, sort), param);
    
                    if (dir == "DESC")
                    {
                        result = result.OrderByDescending(sortExpression);
                    }
                    else
                    {
                        result = result.OrderBy(sortExpression);
                    }
                }
    
                if (start >= 0 &amp;&amp; limit > 0)
                {
                    result = result.Skip(start).Take(limit);
                }
    
                count = db.Employees.Count();
    
                return result.ToList();
            }
            
            protected void Store1_RefreshData(object sender, StoreRefreshDataEventArgs e)
            {
                this.Label1.Text = e.Sort + ":" + e.Dir;
                int count;
                Store1.DataSource = this.GetEmployeesFilter(e.Start, e.Limit, e.Sort, e.Dir.ToString(), out count);
                e.TotalCount = count;
    
                Store1.DataBind();
            }
        </script>
    
        <style type="text/css">
            .x-grid3-td-fullName .x-grid3-cell-inner
            {
                font-family: tahoma, verdana;
                display: block;
                font-weight: normal;
                font-style: normal;
                color: #385F95;
                white-space: normal;
            }
            .x-grid3-row-body p
            {
                margin: 5px 5px 10px 5px !important;
                width: 99%;
                color: Gray;
            }
        </style>
    
        <script type="text/javascript">
            var fullName = function(value, metadata, record, rowIndex, colIndex, store) {
                return '' + record.data.LastName + ' ' + record.data.FirstName + '';
            };
        </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:Store 
                ID="Store1" 
                runat="server" 
                AutoLoad="true" 
                RemoteSort="true" 
                OnRefreshData="Store1_RefreshData">
                <AutoLoadParams>
                    <ext:Parameter Name="start" Value="={0}" />
                    <ext:Parameter Name="limit" Value="={3}" />
                </AutoLoadParams>
                <Proxy>
                    <ext:DataSourceProxy />
                </Proxy>
                <Reader>
                    <ext:JsonReader ReaderID="EmployeeID">
                        <Fields>
                            <ext:RecordField Name="FirstName" />
                            <ext:RecordField Name="LastName" />
                            <ext:RecordField Name="Title" />
                            <ext:RecordField Name="TitleOfCourtesy" />
                            <ext:RecordField Name="BirthDate" Type="Date" />
                            <ext:RecordField Name="HireDate" Type="Date" />
                            <ext:RecordField Name="Address" />
                            <ext:RecordField Name="City" />
                            <ext:RecordField Name="Region" />
                            <ext:RecordField Name="PostalCode" />
                            <ext:RecordField Name="Country" />
                            <ext:RecordField Name="HomePhone" />
                            <ext:RecordField Name="Extension" />
                            <ext:RecordField Name="Notes" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
            
            <ext:GridPanel 
                runat="server" 
                ID="GridPanel1" 
                Title="Employees" 
                Frame="true" 
                StoreID="Store1" 
                Height="300">
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column ColumnID="fullName" Header="Full Name" Width="150" DataIndex="LastName">
                            <Renderer Fn="fullName" />
                        </ext:Column>
                        <ext:Column DataIndex="Title" Header="Title" Width="150" />
                        <ext:Column DataIndex="TitleOfCourtesy" Header="Title Of Courtesy" Width="150" />
                        <ext:Column DataIndex="BirthDate" Header="BirthDate" Width="110">
                            <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
                        </ext:Column>
                        <ext:Column DataIndex="HireDate" Header="HireDate" Width="110">
                            <Renderer Fn="Ext.util.Format.dateRenderer('Y-m-d')" />
                        </ext:Column>
                        <ext:Column DataIndex="Address" Header="Address" Width="150" />
                        <ext:Column DataIndex="City" Header="City" Width="100" />
                        <ext:Column DataIndex="Region" Header="Region" Width="100" />
                        <ext:Column DataIndex="PostalCode" Header="PostalCode" Width="100" />
                        <ext:Column DataIndex="Country" Header="Country" Width="100" />
                        <ext:Column DataIndex="HomePhone" Header="HomePhone" Width="150" />
                        <ext:Column DataIndex="Extension" Header="Extension" Width="100" />
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GridView runat="server" EnableRowBody="true">
                        <GetRowClass Handler="rowParams.body = '<p>'+record.data.Notes+'</p>'; return 'x-grid3-row-expanded';" />
                    </ext:GridView>
                </View>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" />
                </SelectionModel>
                <BottomBar>
                    <ext:PagingToolBar ID="PagingToolBar1" runat="server" PageSize="3" StoreID="Store1"
                        DisplayInfo="true" DisplayMsg="Displaying employees {0} - {1} of {2}" EmptyMsg="No employees to display" />
                </BottomBar>
                <LoadMask ShowMask="true" />
            </ext:GridPanel>
            
            <ext:Label ID="Label1" runat="server" />
        </form>
    </body>
    </html>

  5. #5

    RE: [CLOSED] GridPanel Paging

    Thanks vladimir, you're the best.

    Cheers,
    Timothy

Similar Threads

  1. Gridpanel paging bug
    By kakagu in forum 1.x Help
    Replies: 2
    Last Post: Apr 07, 2012, 1:31 PM
  2. [CLOSED] Paging in Gridpanel
    By mgowder in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 27, 2011, 8:26 AM
  3. [CLOSED] GridPanel Paging
    By cobiscorp in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 21, 2010, 10:29 PM
  4. Paging GridPanel
    By marcmvc in forum 1.x Help
    Replies: 2
    Last Post: Jul 21, 2010, 10:28 PM
  5. GridPanel Paging
    By Yannis in forum 1.x Help
    Replies: 3
    Last Post: Jun 30, 2010, 11:27 PM

Posting Permissions