[CLOSED] Paging Toolbars on DataViews

  1. #1

    [CLOSED] Paging Toolbars on DataViews

    I've been unable to get a Paging Toolbar to work properly with DataViews. In short the e.Total is not being calculated by the toolbar. I do get the e.Start and e.Limit. However, the PagingToolbar thinks that the limit is the count.

    I rebuilt into a very simple example.


    Codebehind
    namespace TestExt
    {
        public partial class Default : System.Web.UI.Page
        {
    
    
            private string[] names =
    @"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"
    .Replace(",", "").Replace("  ", " ").Split(' ');
    
    
    
    
            protected void Page_Load(object sender, EventArgs e)
            {
               
            }
    
    
            // FIRST TRY
            protected void DocList_Refresh(object sender, StoreReadDataEventArgs e)
            {
                if (X.IsAjaxRequest)
                {
                    List<sample> foobar = new List<sample>();
                    for (int i = 0; i < 50; i++)
                        foobar.Add(new sample() { Date = DateTime.Now.AddDays(i), Id = i, Name = names[i] });
    
    
                    e.Total = foobar.Count();
                    this.StoreDocumentList.DataSource = foobar.Skip(e.Start).Take(e.Limit);
                    this.StoreDocumentList.DataBind();
                    
                }
            }
    
    
            // SECOND TRY
            [DirectMethod]
            public object BindData(string action, Dictionary<string, object> extraParams)
            {
                var iStart = 0;
                var iLimit = 10;
                if (extraParams != null)
                {
                    StoreRequestParameters prms = new StoreRequestParameters(extraParams);
                    iStart = prms.Start;
                    iLimit = prms.Limit;
                }
    
    
                List<sample> foobar = new List<sample>();
                for (int i = 0; i < 50; i++)
                    foobar.Add(new sample() { Date = DateTime.Now.AddDays(i), Id = i, Name = names[i] });
    
    
                return foobar.Skip(iStart).Take(iLimit);
    
    
            }    
    
    
           
    
    
    
    
        }
    
    
    
    
        public class sample
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public DateTime Date { get; set; }
        }
    }

    Markup

     <form id="form1" runat="server">
            <ext:resourcemanager runat="server">
            </ext:resourcemanager>
    
    
            <ext:Panel runat="server" ID="pnl1">
                <Items>
                    <ext:Hidden ID="HiddenPersonId" runat="server">
                    </ext:Hidden>
                    <ext:DataView ID="dvDocumentList"
                            runat="server"
                            DisableSelection="true"
                            ItemSelector="tr.customer-record">
                        
                            <Store>
                                <ext:Store ID="StoreDocumentList" runat="server" IDMode="Static" PageSize="10" OnReadData="DocList_Refresh">
                                   <%-- <Proxy>
                                        <ext:PageProxy DirectFn="App.direct.BindData" />
                                    </Proxy>--%>
                                    <Model>
                                        <ext:Model ID="Model1" runat="server">
                                            <Fields>
                                                <ext:ModelField Name="Id" />
                                                <ext:ModelField Name="FileName" />
                                                <ext:ModelField Name="Date"  DateFormat="mm/dd/YYYY"  />  
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>                                        
                            <Tpl ID="Tpl1" runat="server">
                                <Html>
                                    <div>                    
                            <table class="tbl">                    
                            <tpl for=".">                                                                
                                <tr class="customer-record">                                                    
                                    
                                <td>
                                        <label>Record {Id}</label>
                                    <br />
                                    <b>
                                        <label>{FileName}</label>
                                    </b>
                                    <p />
                                        <label>{Date}</label> 
                                </td>
    
    
                            </tr>                                                                                                                                     
                            </tpl>                    
                        </table>
                    </div>
                                </Html>
                            </Tpl>
                        </ext:DataView>
                </Items>
              <TopBar>             
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" StoreID="StoreDocumentList" HideRefresh="false">
    
    
                    </ext:PagingToolbar>             
               </TopBar> 
            </ext:Panel>
        </form>
    Last edited by Daniil; Mar 11, 2014 at 6:38 AM. Reason: [CLOSED]
  2. #2
    Hi @Juls,

    You have to return the total amount from the BindData method. As here:
    https://examples2.ext.net/#/GridPane.../DirectMethod/

Similar Threads

  1. Replies: 0
    Last Post: Feb 27, 2012, 5:26 AM
  2. Replies: 1
    Last Post: Aug 22, 2011, 5:54 PM
  3. [CLOSED] Width of toolbars and headers on a Grid
    By wazige in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 07, 2010, 10:20 AM
  4. Multiple toolbars emulation
    By Vladimir in forum Examples and Extras
    Replies: 4
    Last Post: Sep 24, 2009, 6:18 AM
  5. [CLOSED] Toolbars and Menus in extjs....
    By king1231986 in forum 1.x Help
    Replies: 1
    Last Post: Nov 06, 2008, 4:40 AM

Tags for this Thread

Posting Permissions