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

Refresh #60

Closed
FraGoTe opened this issue Jan 19, 2016 · 8 comments
Closed

Refresh #60

FraGoTe opened this issue Jan 19, 2016 · 8 comments
Assignees
Labels

Comments

@FraGoTe
Copy link

FraGoTe commented Jan 19, 2016

Hi, is there a way to refresh the table via ajax with an external button?

@FraGoTe FraGoTe changed the title Refesh Refresh Jan 19, 2016
@iamisti iamisti self-assigned this Jan 21, 2016
@iamisti
Copy link
Owner

iamisti commented Jan 21, 2016

Hi @FraGoTe, this is not possible at the moment. Only if you provide data with the non-ajax way. That case it'll automatically refresh when your data object changes.

@bigosmallm
Copy link

Is there a workaround for this? What is the best way to refresh the table which has pagination via ajax?

@bigosmallm
Copy link

Update: I figured out that we can use the ng-if to momentarily remove the table off the DOM and re-add it. This causes the table to instantiate itself again and call the paginator callback function, essentially refreshing it externally.

Here is a codepen showing this solution: http://codepen.io/anon/pen/yJVXLw

@iamisti
Copy link
Owner

iamisti commented Oct 6, 2016

It is possible for a while which gives you a much better performance and user experience:

From the documentation

|:white_check_mark:| mdt-trigger-request | function(loadPageCallback) | optional, if mdt-row-paginator set, provides a callback function for manually triggering an ajax request. Can be useful when you want to populate the results in the table manually. (e.g.: having a search field in your page which then can trigger a new request in the table to show the results based on that filter. |

@iamisti iamisti closed this as completed Oct 6, 2016
@NBAMj
Copy link

NBAMj commented Nov 17, 2016

Can you provide an example of how to use mdt-trigger-request when using Ajax Column Filter Support ?
the function mdt-trigger-request is being called after my ajax insert call, but the passed parameter "loadPageCallback" is undefined .

@Spragalas
Copy link

How to use that?

@ryankidd
Copy link

ryankidd commented Jan 12, 2017

I'm on my first Angular project. I may not be the best to explain, but this works.

Add this to your mdt-table directive:

mdt-trigger-request="getLoadResultsCallback(loadPageCallback)"

Now in your controller, add this:

var loadPageCallbackWithDebounce;
$scope.getLoadResultsCallback = function(loadPageCallback){
loadPageCallbackWithDebounce = _.debounce(loadPageCallback, 1000);
}

Now whenever you call loadPageCallbackWithDebounce(), the paginator function gets run again.

Here is an example of how to call:

$scope.deleteInvoices = function(rows){

    _.forEach( rows, function( value, key ) {
            Invoices.delete({id:value});
    });  

    if(loadPageCallbackWithDebounce){
          loadPageCallbackWithDebounce();  
   }        

});
}

@nojaf
Copy link

nojaf commented Feb 3, 2017

@Spragalas , maybe a bit late but there is an example on http://codepen.io/iamisti/pen/RRrjLk?editors=1010

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

7 participants