Smart-Table
Smart-Table copied to clipboard
pipe called twice when st-template is used in pagination
Here's a plunker: http://plnkr.co/edit/IdQx5OQ9PgSiIMedOTSY If you remove st-template it calls the pipe only once.
Seeing same issue
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.
And what if you put the template in the $templateCache (to avoid the http request) ?
+1, same issue
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>
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..
Having similar issue. Had this issue when using ng-if. Replacing it with ng-show fixed it. But sometimes it happens randomly.
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();
};
I encountered this issue with and without using st-template. Changing the pipe delay to 200ms seems to resolve it.
pipe: { delay: 200 //ms }
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.
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; } .... }
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
Try to change ng-if
to ng-show
, it works for me
It will work if you remove these code in 'stPagination' directive: