[CLOSED] Automatically update page number in PagingToolbar

  1. #1

    [CLOSED] Automatically update page number in PagingToolbar

    Hi!

    I'm using a GridPanel with PagingToolbar(StoreID also associated). When i go to page 2, for example, and after this i call Store.Reload(), passing new parameters, the store's records are renewed starting in 0, but the page number stays in 2. Is this correct?

    Thanks!
    Last edited by fabricio.murta; Dec 05, 2016 at 5:39 PM.
  2. #2
    Hello @banrisulssw!

    If I try your described issue in this example (direct load and open debugging console): GridPanel - Paging and Sorting - DirectMethod

    If I switch then to page 2 or 3, and then in console call App.Store1.reload(), it loads correctly, keeping at page 2.

    Can you provide a test case which reproduces the issue so we can see what's happening? Maybe if you take a look on the example linked above you can figure out what's wrong with your approach too.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello Fabricio!

    The .ASPX source code is below:

        <ext:GridPanel ID="gpLogsPxhUtils"
            runat="server"
            Border="true"
            EmptyText="Nenhuma Informação."
            Cls="fundoDefaultInterna">
            <TopBar>
                <ext:Toolbar runat="server" ID="TopToolBar1" DefaultButton="btFilter" Layout="ColumnLayout">
                    <Items>
                        <ext:ComboBox ID="cbProgram" runat="server" EmptyText="Filtrar por programa" ColumnWidth="0.3" />
                        <ext:ComboBox ID="cbLogLevel" runat="server" EmptyText="Filtrar tipo de Log" ColumnWidth="0.2" />
                        <ext:ComboBox ID="cbUsers" runat="server" EmptyText="Filtrar por usuário" ColumnWidth="0.3" />
                        <ext:DateField ID="dateFieldInitial" runat="server" EmptyText="Data inicial"></ext:DateField>
                        <ext:DateField ID="dateFieldFinal" runat="server" EmptyText="Data final"></ext:DateField>
                        <ext:Button ID="btFilter" runat="server" Icon="Magnifier" 
                            OnDirectClick="btFilter_DirectClick" 
                            ToolTip="Pesquisar"></ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <Store>
                <ext:Store ID="StoreLogs"
                    runat="server"
                    PageSize="100"
                    OnReadData="StoreLogs_ReadData">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Model>
                        <ext:Model ID="ModelLogs" runat="server">
                            <Fields>
                                <ext:ModelField Name="IdLog" Type="Int" />
                                <ext:ModelField Name="TipoLog" Type="String" />
                                <ext:ModelField Name="Transacao" Type="String" />
                                <ext:ModelField Name="Usuario" Type="String" />
                                <ext:ModelField Name="DataHora" Type="String" />
                                <ext:ModelField Name="Mensagem" Type="String" />
                                <ext:ModelField Name="Observacao" Type="String" />
                                <ext:ModelField Name="NomeServidor" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                    <AutoLoadParams>
                        <ext:Parameter Name="start" Value="1" Mode="Raw" />
                        <ext:Parameter Name="limit" Value="100" Mode="Raw" />
                    </AutoLoadParams>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column ID="clLogID" runat="server" Text="LogID" DataIndex="IdLog" Flex="1" Sortable="false" Hidden="true" />
                    <ext:Column ID="clLogLevel" runat="server" Text="Tipo" DataIndex="TipoLog" Flex="2" Sortable="false" />
                    <ext:Column ID="clAppName" runat="server" Text="Programa" DataIndex="Transacao" Flex="4" Sortable="false" />
                    <ext:Column ID="clUsercode" runat="server" Text="Usuário" DataIndex="Usuario" Flex="7" Sortable="false" />
                    <ext:Column ID="clDate" runat="server" Text="Data/Hora" DataIndex="DataHora" Flex="4" Sortable="false" />
                    <ext:Column ID="clMessage" runat="server" Text="Mensagem" DataIndex="Mensagem" Sortable="false" Flex="12" />
                    <ext:Column ID="clObservacao" runat="server" Text="Observação" DataIndex="Observacao" Flex="1" Sortable="false" Hidden="true" />
                    <ext:Column ID="clNomeServidor" runat="server" Text="IIS" DataIndex="NomeServidor" Flex="1" Sortable="false" Hidden="true" />
                </Columns>
            </ColumnModel>
            <BottomBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:PagingToolbar ID="pager" runat="server" StoreID="StoreLogs"></ext:PagingToolbar>
                        <ext:ToolbarFill></ext:ToolbarFill>
                        <ext:Button ID="btnExportaExcel" 
                            runat="server"
                            Text="Exportar para Excel"
                            Icon="PageExcel"
                            AutoPostBack="true"
                            OnClick="ToExcel"
                            OnClientClick="#{btnExportaExcel}.disable();">
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </BottomBar>
        </ext:GridPanel>
    The server side code is below:

            protected void StoreLogs_ReadData(object sender, StoreReadDataEventArgs e)
            {
                master = (Site1)this.Master;
                using (DBPxhManager sql = new DBPxhManager())
                {
                    string program = string.IsNullOrEmpty(this.cbProgram.SelectedItem.Value) ? null : this.cbProgram.SelectedItem.Value;
                    string logLevel = string.IsNullOrEmpty(this.cbLogLevel.SelectedItem.Value) ? null : this.cbLogLevel.SelectedItem.Value;
                    string user = string.IsNullOrEmpty(this.cbUsers.SelectedItem.Value) ? null : this.cbUsers.SelectedItem.Value;
                    DateTime? initial = this.dateFieldInitial.SelectedDate == DateTime.MinValue ? (DateTime?)null : (DateTime?)this.dateFieldInitial.SelectedDate;
                    DateTime? final = this.dateFieldFinal.SelectedDate == DateTime.MinValue ? (DateTime?)null : (DateTime?)this.dateFieldFinal.SelectedDate;
                    int pageNumber = e.Page;
                    int rowsperpage = e.Limit;
    
                    int TotalRows;
    
                    DataTable tab = sql.usp_Log_Search(program, logLevel, user, initial, final, pageNumber, rowsperpage, out TotalRows);
    
                    DataTable finalTable = new DataTable();
                    finalTable.Columns.Add("IdLog");
                    finalTable.Columns.Add("TipoLog");
                    finalTable.Columns.Add("Transacao");
                    finalTable.Columns.Add("Usuario");
                    finalTable.Columns.Add("DataHora");
                    finalTable.Columns.Add("Mensagem");
                    finalTable.Columns.Add("Observacao");
                    finalTable.Columns.Add("NomeServidor");
    
                    foreach (DataRow r in tab.Rows)
                    {
                        DataRow nr = finalTable.NewRow();
                        nr["IdLog"] = r["IdLog"];
                        nr["TipoLog"] = r["TipoLog"];
                        nr["Transacao"] = r["Transacao"];
                        nr["Usuario"] = r["Usuario"];
                        nr["DataHora"] = r["DataHora"].ToString();
                        nr["Mensagem"] = r["Mensagem"];
                        nr["Observacao"] = r["Observacao"];
                        nr["NomeServidor"] = r["NomeServidor"];
    
                        finalTable.Rows.Add(nr);
                    }
    
                    e.Total = TotalRows;
    
                    this.StoreLogs.DataSource = finalTable;
                    this.StoreLogs.DataBind();
                }
            }
    
            protected void btFilter_DirectClick(object sender, DirectEventArgs e)
            {
                this.StoreLogs.Reload();
                btnExportaExcel.Enable();
            }
    After StoreLogs.Reload() is called, i need to start by page 1, by default.

    For an example: I'm on page 3, then i change some search parameter, and call Reload() again, which will bring 50 results, but i'm showing 100/page. The search result will be "Not found", beacause i'm on page 3.

    Tanks!!
  4. #4
    Hello,

    We can't reproduce the sample here for at least two reasons:
    - master page references in the sample
    - specific/private classes

    Do you think you can reduce your test case for an aspx code without the need of that specific SQL class (could a static object or small class with, maybe, idlog and mensagem, and fictitious contents, represent your data?).

    The reason we need a runnable sample is so that we can debug it both in Visual Studio and from browser.
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Hello Fabricio!

    Sorry for the delay. I solved the problem using the Store.LoadPage(1), after the new parameters being pass.

    Thanks!
  6. #6
    Hello! Thanks for the feedback and for letting us know you could fix the issue! If there's something else you think we can help you with, don't hesitate to ask!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Update page number on grid panel
    By ingbabic in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Jan 30, 2016, 5:22 PM
  2. Update page number in Paging toolbar
    By ingbabic in forum 2.x Help
    Replies: 0
    Last Post: Sep 04, 2014, 4:14 PM
  3. Number of page in PagingToolbar
    By Dominik in forum 1.x Help
    Replies: 1
    Last Post: Dec 16, 2010, 12:16 PM
  4. [CLOSED] Update Store Automatically every 5 minute.
    By farisqadadeh in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Dec 11, 2010, 9:31 PM
  5. Replies: 0
    Last Post: Dec 02, 2010, 9:01 PM

Tags for this Thread

Posting Permissions