Git Product home page Git Product logo

Comments (12)

triniwiz avatar triniwiz commented on September 25, 2024

Are you using this.numItems anywhere in the view?

from nativescript-pager.

LauraNavarroGalvan avatar LauraNavarroGalvan commented on September 25, 2024

yes, I use this to calculate the number of pages and to change the buttons that are displayed in the view

<GridLayout row="3" rows="auto" columns="*, *" class="main-activity">
        <Button text="Prev" (tap)="prevPage()" class="btn btn-primary" col="0" *ngIf="latestReceivedIndex != 0"></Button>
        <Button text="Next" (tap)="nextPage()" class="btn btn-primary" col="1" *ngIf="latestReceivedIndex != (numItems-1)"></Button>
        <Button text="Save" (tap)="saveForms()" class="btn btn-primary" col="1" *ngIf="latestReceivedIndex == (numItems-1)"></Button>
    </GridLayout>

from nativescript-pager.

triniwiz avatar triniwiz commented on September 25, 2024

So it’s the buttons that doesn’t update no?

from nativescript-pager.

LauraNavarroGalvan avatar LauraNavarroGalvan commented on September 25, 2024

no, the problem is not the buttons, the problem is when I insert an object in the middle of two pages, the new object it is shown in another part or with wrong information (usually duplicates the last page) and when I delete an object always removes me the last page. however when I review the BehaviorSubject object in the console, this is fine but in the view not and this only happens in ios.

from nativescript-pager.

triniwiz avatar triniwiz commented on September 25, 2024

Can you try calling .refresh(true) on the pager after you update it ?

from nativescript-pager.

HoangJK avatar HoangJK commented on September 25, 2024

@triniwiz
I think I have same problem #66
When I use unshift in items, it update wrong data in Pager.

from nativescript-pager.

HoangJK avatar HoangJK commented on September 25, 2024

I have items = [1, 2, 3], Pager show 3 page, it ok.
I use items.unshift(0); this.pager.nativeElement.refresh(true) ;

console.log(items) => [0, 1, 2, 3]

But Pager show data: 0 - 1 - 3 - 3

from nativescript-pager.

LauraNavarroGalvan avatar LauraNavarroGalvan commented on September 25, 2024

it still doesn't work @triniwiz and @HoangJK it's the same error

from nativescript-pager.

LauraNavarroGalvan avatar LauraNavarroGalvan commented on September 25, 2024

if I refresh the items as shown in the code below, it works, but the UX is ugly, because the previous page is first displayed and then the new page.
for example if I have items = [1,2,3]
and I update it to items = [1,2, new, 3]
First he shows me page 3 and after a few seconds the new page is shown, which makes the user thing as an error.

prevPage() {
	this.pager.nativeElement.refresh(true);
	const newIndex = Math.max(0, this.currentPagerIndex - 1);
	this.currentPagerIndex = newIndex;
	this.pager.nativeElement.selectedIndex = newIndex;
}

// Go to the next page
nextPage() {
	this.pager.nativeElement.refresh(true);
	const newIndex = Math.min(this.numItems - 1, this.currentPagerIndex + 1);
	this.currentPagerIndex = newIndex;
	this.pager.nativeElement.selectedIndex = newIndex;
}

// Change de Index of the page
onIndexChanged($event) {
	this.pager.nativeElement.refresh(true);
	this.latestReceivedIndex = $event.value;
	this.currentPagerIndex = $event.value;
}
addQuestion() {
	let newItems = (<BehaviorSubject>this.formItems).value;
	newItems.splice(indexPage+1, 0, newQuestion);
	this.formItems.next(newItem);
	this.pager.nativeElement.refresh(true);

}

from nativescript-pager.

triniwiz avatar triniwiz commented on September 25, 2024

Thanks for the info 😃

from nativescript-pager.

triniwiz avatar triniwiz commented on September 25, 2024

Can you try the latest version :)

from nativescript-pager.

triniwiz avatar triniwiz commented on September 25, 2024

This is fixed in the latest release

from nativescript-pager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.