Issues relating to the total count of pages in the uib-pagination component of AngularJS

While there is a previous thread discussing a similar topic Calculating total items in AngularJs Pagination (ui.bootstrap) doesn't work correctly, it does not address my specific issue and I am unsure how to contribute to it.

We are using a complex smList directive with the following HTML at the bottom of the page:

<div class="text-center" ng-show="vm.table.pageCount > 1">
  <ul uib-pagination 
      total-items="vm.table.totalCount"
      ng-model="vm.table.pageNumber"
      items-per-page="vm.table.pageSize"
      max-size="5"
      rotate="false"
      ng-change="vm.selectPage()"
      previous-text="@Labels.previous"
      next-text="@Labels.next"></ul>
</div>

In certain scenarios, the total number of pages does not update correctly. For example, if I perform a search with a filter and get 4 pages, then remove the filter, I should see more than 5 pages. However, I still see only 4 pages even though the controller table.totalCount reflects the correct numbers when traced through the code.

What steps can we take to resolve this issue? Should we reset totalCount to 0 before running a new search?

In the search function that retrieves results from the server, the code snippet looks like this:

.then(function (data) {
                log.debug("After main search return...");

                self.results = data.list;
                self.table.totalCount = data.totalCount;
                self.table.pageCount = data.pageCount;
                self.table.pageSize = data.pageSize;
                self.table.pageNumber = data.pageNumber;                

                self.showResults = true;

Instead of setting total items manually, could we make use of the pagecount returned by the server (since calculations are already done there)? Is there a way to set the pagecount for uib-pagination instead of total-items?

Answer №1

UPDATE: The root of the issue was found in our RowClick directive code. Simply commenting out a single line fixed the problem entirely.

Although not a definitive solution, it appears that the bug only manifests when opening the edit form.

The layout of the index page is as follows:

<div ng-controller="DynamicRulesController">
    <div ng-controller="dynamicRulesSearchController">
        <data-sm:list data-name="dynamicRules"
                      data-table="table"
                      data-hide-hidden-filter="true"
                      data-show-search="true"
                      data-can-hide-search="false"
                      data-on-before-new-record="onBeforeNewRecord"  
                      data-dont-go-to-new-state="true"                   
                      data-pk="ruleId"
                      data-param-id="id"
                      data-heading="heading">
        </data-sm:list>     
    </div>

    <div class="edit-container ng-cloak" ng-show="!isEditLoading" ui-view autoscroll="false"></div>
</div>

Functionality works seamlessly on the index page until the Edit form (ui-view) is accessed, at which point pagination malfunctions. It seems to be connected to states and ui-view interaction.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript generated by PHP not functioning on IE version 7 and above

I've been experimenting with JavaScript generated from PHP, but I've run into issues specifically with Internet Explorer. While other browsers such as Firefox and Chrome have successfully processed and executed the JS code. As an example, you ca ...

What steps should be taken to prepare files (such as editing images) before they are uploaded to Google Drive using the `rpldy/drive-uploady` tool?

I have successfully implemented rpldy/drive-uploady to upload files to Google Drive. However, I would like to allow users to edit images before uploading them. How can I achieve this? Below is the code snippet: import DriveUploady from "drive-uploady ...

Organizing DIVs upon website initialization

My website features a layout with three columns: <div id="column1"></div> <div id="column2"></div> <div id="column3"></div> I currently have 3 divs on the webpage: <div id="1">aaa</div> <div id="2">b ...

Exploring the possibilities of socket.io-client in combination with Vite.js and Vue for seamless real

I am currently diving into socket.io for my upcoming Vue project, but I seem to be encountering some issues. Interestingly, everything works smoothly when I use vue-cli, however, I prefer working with Vite.js due to its speed and customization options. Unf ...

Using jQuery to retrieve the content of a textarea and display it

I need help finding the right way to read and write to a Linux text file using JavaScript, jQuery, and PHP. Specifically, I want to retrieve the value from a textarea (#taFile) with jQuery ($("#taFile").val();) and send it via $.post to a PHP script that w ...

It is not possible to trigger an input click programmatically on iOS versions older than 12

Encountering a challenge in triggering the opening of a file dialogue on older iOS devices, particularly those running iOS 12. The approach involves utilizing the React-Dropzone package to establish a dropzone for files with an added functionality to tap ...

Having trouble properly refreshing Bootstrap scrollspy that is spying on the <body> element

I've been looking at a post on Bootstrap's scrollspy component (found here). In my code, I initialize a new scrollspy to track the body element using: $("body").scrollspy({ offset: 25 }); As my code progresses, I make AJAX requests that add or ...

Troubleshooting: Issues with $location.path not updating in AngularJs

While I understand that this issue has been discussed previously, none of the provided solutions seem to work. I have a good understanding of Angular and have written a substantial amount of Angular code, so I am not a novice in this field. Currently, I ...

Tips for creating a vertical Angular Material slider with CSS

Attempting to modify the angular material directive to render vertically has been a challenge. I experimented with using transform:rotate in the CSS, however, it resulted in the slider behaving and rendering differently. md-slider { position: absolute ...

The Vue/Nuxt application displays content duplication on each page, rendering the content twice without duplicating the components

I recently delved into Vue/Nuxt programming and worked through a tutorial on adding a blog, which I then customized for my website. Everything functions perfectly except that the content is rendering twice. It goes from rendering NavPage (component) > cont ...

ReactJS sidebar navigation functionality

I have a fixed sidebar with icons for navigating to different pages. When an icon is clicked, a secondary menu slides out. However, the issue is that when another icon is selected, the menu slides back in instead of switching or staying out. Additionally, ...

Is there a way to convert the existing JavaScript code for a hyperlink so that it can be triggered by clicking a button instead?

I have a JavaScript code that works well when the hyperlink below is clicked: <a href="delete_event.php?event_id=110" onClick="return ConfirmDelete()" class="list-group-item">Delete Event</a> <script> function ConfirmDelete() { var ans ...

Transferring a Query between Domains with the Help of JavaScript

It is necessary to develop a function that generates a query based on the user's input of "Test" in an INPUT on Site A (SiteA.com) and then redirects to Site B within the same window, passing along the query (SiteB.com/search.aspx?k=test). Code snipp ...

What are the recommended margins for various alphabets?

When displaying text, some alphabets take up more space than others. So how can I adjust the white space between elements '#re1' and '#re2' automatically in the scenario described below? In this code snippet, what is the best way to ad ...

Customize Tab indicator styling in Material-UI

Currently, I am attempting to customize the MUI tab by changing the indicator from a line to a background color. Through my research, I discovered that using TabIndicatorProps and setting a style of display:none eliminates the indicator completely. However ...

Retrieve the initial value of the input element following a modification

Is there a way to retrieve the original default value of an input field after changing it using .val()? In my HTML, I have various text-inputs with classes .large and .medium, each with its own default text value. What I'm trying to achieve is when a ...

How to use Vue v-bind to fetch an array object from a different array iteration

I am currently working on a project where I have developed a table component that is utilized across multiple pages with different configurations. Each table has its own configuration stored in a separate file, containing keys, titles, and size classes for ...

SignalR enables the display of identical dashboard data pulled from queries on various browsers. By utilizing SignalR/hub, MVC, and C#.NET, the data can

Encountering an issue with my signalr/hub while fetching dashboard data. I'm using 2 browsers to access data based on dates. However, when searching for July on browser 1 and then switching to another month on browser 2, the data in browser 1 gets upd ...

Issues with splicing an Angular array using pure JavaScript

Could someone please help me figure out what I'm doing incorrectly? I have some JSON data that I am converting into an array for use in an ng-repeat. Before looping through the array, I am checking the event dates against today's date and removin ...

The constructor for audio in Next JS cannot be found

I'm facing an issue and struggling to find a solution. My project follows the standard structure of Next JS. In the root directory, I have included a components folder. Within the components folder, there is a component with the following code: imp ...