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

st-pipe function is being called twice in a row #329

Closed
yanivkalfa opened this issue Mar 11, 2015 · 20 comments
Closed

st-pipe function is being called twice in a row #329

yanivkalfa opened this issue Mar 11, 2015 · 20 comments
Labels

Comments

@yanivkalfa
Copy link

Not really sure whats going on but st-pipe function is being called twice in a row which isnt ideal,

@lorenzofox3
Copy link
Owner

Most of the directives trigger a call to pipe function whenever the table state change, normally it is one shot but there could be side effects. Can you show me what your table look like ?

@yanivkalfa
Copy link
Author

Please take a look at:
http://plnkr.co/edit/EDdItB54ZXKSVZkOkSF7?p=preview

I've built this base on you ajax plugin example.

@lorenzofox3
Copy link
Owner

yep you are right, I think the pagination directive when linking changes somehow the tableState define here which triggers a call to pipe function (the first one is from the post link function of the main directive). I need to investigate a bit more. Meanwhile, as a workaround, I suggest you cache you http request or check manually in you custom pipe function to avoid duplicate call for what should be the same tableStae

@yanivkalfa
Copy link
Author

meanwhile as a solution we have a flag in place.

@smebberson
Copy link

I'm experiencing this too!

@alainlecluse
Copy link

Samething here.

@alainlecluse
Copy link

Just found out that it's not just st-pagination but also st-sort-default. @ version 2.0.1.
My tables with pipe calls the function 6 times.

@smajl
Copy link

smajl commented Apr 1, 2015

Confirmed. pagination and st-sort-default do this. :( So I am now using something like:

...
if (angular.equals(tableState, this.previousTableState)) return;
this.previousTableState = angular.copy(tableState);
...

@yanivkalfa
Copy link
Author

@lorenzofox3, what will one do if one desires to override your default pipe / sort by behavior ? how can i extend on your controller ?

Say i want to add a multi-sort client side, i need a way to override pipe. overriding sortBy is easy because you have only tableState variable to worry about and you have a method to get that. but pipe has several others variables...

@Darksoulsong
Copy link

Issue is still happening in version 2.1.6, same use case.

@rockccf
Copy link

rockccf commented Jan 14, 2016

Yes, using version 2.1.6 and it's still happening.
When is this going to be fixed?
Thanks.

@rafaelhz
Copy link

rafaelhz commented Mar 8, 2016

It still happening when included st-pagination. (version 2.1.7)

@tistvan
Copy link

tistvan commented Apr 19, 2016

I just updated smartTable to 2.1.8 and i still have 2 calls. The first without sort and the second with sort. I am using st-sort-default directive.

@Marcosdg3
Copy link

Marcosdg3 commented Apr 26, 2016

Removing st-sort-default="true" on the table column fixed my issue. The st-pipe function I have defined is only called once now.

@JinPink
Copy link

JinPink commented Jun 27, 2016

I had debugged this issue and resolved it.
Reason:
the code at the end of 'stPagination' directive(v2.1.8)

490        if (!ctrl.tableState().pagination.number) {
491          ctrl.slice(0, scope.stItemsByPage);
492        }

Solution:
initialise tableState.pagination.number in your pipe service.
tableState.pagination.number = vm.numPerPage;

@csabaujvari
Copy link

I updated smart table to the latest version, but still having this issue with st-sort-default directive.

I found an alternative solution. A bit hackish, sorry :(

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

@newbro
Copy link

newbro commented Sep 28, 2016

I was trying to implement persistence tableState for ajax call and seems restoring tableState will cause pipe function being called twice as mention here. Is there any fix in plan?

@swatifursule
Copy link

What is workaround or fix for this?

@rockccf
Copy link

rockccf commented Jan 16, 2017

Refer to MrWook's reply in issue 734,

Probably the problem occurs when you use sort with the pipe directive and like i said in #388

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
To provide you with some more help:
app.config([ 'stConfig', function(stConfig) { stConfig.sort.delay = 100; stConfig.pipe.delay = 200; }]);

@johnico
Copy link

johnico commented Feb 24, 2017

.config([ 'stConfig', function(stConfig) { stConfig.sort.delay = 100; stConfig.pipe.delay = 200; }])

solved my issue too
thx a lot

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