Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipe called twice when st-template is used in pagination #388

Open
gmq opened this issue Apr 28, 2015 · 14 comments
Open

pipe called twice when st-template is used in pagination #388

gmq opened this issue Apr 28, 2015 · 14 comments
Labels

Comments

@gmq
Copy link

gmq commented Apr 28, 2015

Here's a plunker: http://plnkr.co/edit/IdQx5OQ9PgSiIMedOTSY
If you remove st-template it calls the pipe only once.

@gmq gmq changed the title stPipe called twice when st-template is used in pagination pipe called twice when st-template is used in pagination Apr 28, 2015
@pheuter
Copy link
Contributor

pheuter commented Apr 29, 2015

Seeing same issue

@kiddo13
Copy link

kiddo13 commented Jun 27, 2015

Here too. But if you use the stConfig.pagination.template, it got called only once.
So, I think the problem is the st-template attribute.

@lorenzofox3
Copy link
Owner

And what if you put the template in the $templateCache (to avoid the http request) ?

@StyleT
Copy link

StyleT commented Aug 11, 2015

+1, same issue

@AdamSelene
Copy link

Same issue here (st-template is in the $templateCache). The issue is not only with st-template: I have the same one with a simple ng-if to hide the pagination row if number of pages is 0 or 1 ("smartTable" is the smartTable controller that I'm exposing in the scope through a custom directive)
So accessing the pagination object triggers a request.

<tr>
  <td ng-if="smartTable.pagination.numberOfPages >= 2" colspan="12" class="text-center">
    <div st-pagination="" st-items-by-page="10" st-displayed-pages="7"></div>
  </td>
</tr>

@koraybalci
Copy link

Having a similar issue here with pipe and pagination (without st-template). Initially my pipe function called twice with two trips to server, tried to play with pipe.delay as follows:

stConfig.pipe.delay = 500; // default 100ms

But the issue pops up on different clients (so sounds like a race condition somewhere).

Not sure if this is a separate issue..

@logeshthedev
Copy link

Having similar issue. Had this issue when using ng-if. Replacing it with ng-show fixed it. But sometimes it happens randomly.

@llafuente
Copy link

Hi,
I try to debug this issue. Because I have it without the use of st-template

Here is the updated plunker with the issue fixed.

http://plnkr.co/edit/rGTv2qOGGlvgzc767LKW?p=preview

But has some problems... that's why I don't submit a PR, I hope @lorenzofox3 can take over now that the debugging work is done...
here is another possible fix:

//stTable.js
    this.slice = function splice (start, number) {
      tableState.pagination.start = start;
      var n = tableState.pagination.number;
      tableState.pagination.number = number;
      if (n !== undefined)
        return this.pipe();
    };

@Sherzy
Copy link

Sherzy commented Apr 20, 2016

I encountered this issue with and without using st-template. Changing the pipe delay to 200ms seems to resolve it.

pipe: { delay: 200 //ms }

@poziomek
Copy link

I'm also interested in fixing this issue.
Increasing pipe delay to 400ms (minimal threshold in my case) is not a perfect solution in my case.
Regards.

@MrWook
Copy link
Contributor

MrWook commented Sep 19, 2016

This also appears for st-sort-default.
@csabaujvari showed a workaround for this situation in this issue report:
#329

vm.callServer = function (tableState) {
if(!vm.firstLoadIsDone) {
vm.firstLoadIsDone = true;
return;
}
....
}

@MrWook
Copy link
Contributor

MrWook commented Oct 13, 2016

I used my previous answer for a while and find out that it destroy my Table page caching system so I decided to increase the pipe delay to 400ms. I really don't like this because i see this delay maybe not the customer but i see it.
Now i was thinking about the reason behind it why the increase of the delay fixed this issue.
I decided to look throw the SmartTable.js file and i saw that the sorting have a delay to so i decrease the delay from the sorting and set the delay from the pipe right above it.
The pipe delay need to be higher than the sort delay

@krzyhan
Copy link

krzyhan commented Feb 23, 2017

Try to change ng-if to ng-show, it works for me

@AvenKo
Copy link

AvenKo commented Mar 13, 2017

It will work if you remove these code in 'stPagination' directive:
screen shot 2017-03-13 at 11 24 08 am

MrWook added a commit to MrWook/Smart-Table that referenced this issue Jul 3, 2017
Added parameter to the sort function which is only be used for the sortDefault behaviour for the first call. To fix the problem that the pipe called twice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests