Smart-Table icon indicating copy to clipboard operation
Smart-Table copied to clipboard

pipe called twice when st-template is used in pagination

Open gmq opened this issue 9 years ago • 14 comments

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

gmq avatar Apr 28 '15 21:04 gmq

Seeing same issue

pheuter avatar Apr 29 '15 22:04 pheuter

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.

kiddo13 avatar Jun 27 '15 04:06 kiddo13

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

lorenzofox3 avatar Jun 27 '15 07:06 lorenzofox3

+1, same issue

StyleT avatar Aug 11 '15 10:08 StyleT

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>

AdamSelene avatar Sep 07 '15 14:09 AdamSelene

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..

koraybalci avatar Nov 11 '15 01:11 koraybalci

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

logeshthedev avatar Jan 04 '16 21:01 logeshthedev

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();
    };

llafuente avatar Mar 04 '16 13:03 llafuente

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

pipe: { delay: 200 //ms }

Sherzy avatar Apr 20 '16 21:04 Sherzy

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.

poziomek avatar May 25 '16 07:05 poziomek

This also appears for st-sort-default. @csabaujvari showed a workaround for this situation in this issue report: https://github.com/lorenzofox3/Smart-Table/issues/329

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

MrWook avatar Sep 19 '16 11:09 MrWook

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

MrWook avatar Oct 13 '16 12:10 MrWook

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

krzyhan avatar Feb 23 '17 11:02 krzyhan

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

AvenKo avatar Mar 13 '17 03:03 AvenKo