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

Server side refresh not working when using Post #219

Open
WestDiscGolf opened this issue Jul 21, 2016 · 5 comments
Open

Server side refresh not working when using Post #219

WestDiscGolf opened this issue Jul 21, 2016 · 5 comments
Assignees
Labels
Milestone

Comments

@WestDiscGolf
Copy link

WestDiscGolf commented Jul 21, 2016

Hi,

We are using the ng-tasty table with the server side data option. The getResource functionality works fine with pagination and sorting etc. until I add ...

bind-reload="reloadCallback"

... to allow to force a reload of the data (after I delete a record) and then it stops rendering any data at all!

The server side end point is expecting a Http POST to get the data with the table required parameters in the payload from the paramsObj parameter.

I have followed the example from the documentation site and as far as I can see it's due to the POST instead of GET methodology of getting the data.

I think I've narrowed it down to ... https://github.com/Zizzamia/ng-tasty/blob/v0.6.1/src/component/table.js#L226
... as it seems to only set the $scope.url with building up a query string and not using paramsObj however I can't get it to fire off the $scope.reload() function to use the resourceCallback.

How can I get it to work with POST? Is there a way to hook directly into the setDirectivesValues function on the TableController to force the refresh?

Thanks

@Disane87
Copy link

Same here. Did you manage do get it working?

@WestDiscGolf
Copy link
Author

The work around I did in the end was to add a new watch to a property on tasty table, when the property changed it triggered the server side code to execute the fetch.

So I made the following changes:

  1. add 'bindRefresh' to listScopeToWatch

  2. remove the build url call as no point from if (vm.start) code ....

         } else if ($scope.reload) {
          //$scope.url = buildUrl($scope.params, $scope.filters);
  1. In 'updateServerSideResource' underneath if ((initNow || updateFrom == 'params') && ... to add in
     if ($scope.refresh && updateFrom === 'refresh') {
        updateServerSideResource();
    }
  1. Add new item to the watchcollection ...
  $scope.$watchCollection('refresh', function (newValue, oldValue) {
      if (newValue !== oldValue) {
          if ($scope.clientSide) {
              $scope.$evalAsync(updateClientSideResource('refresh'));
          } else {
              $scope.$evalAsync(updateServerSideResource('refresh'));
          }
      }
  }, true);

It seems a bit hacky but at the moment it works :)

Hope it helps!

@Disane87
Copy link

Thanks! could you send me your edited file? I really struggle with the implementation or could you answer me following questions, according your approach?

  1. add 'bindRefresh' to listScopeToWatch
  2. Add new item to the watchcollection ...
    Do I have to do this in the tastyTable.js or in my code?

@WestDiscGolf
Copy link
Author

I made the changes in the ng-tasty-tpls.js file

@Disane87
Copy link

It works, thanks you! :)

@Zizzamia Zizzamia added the bug label Dec 31, 2016
@Zizzamia Zizzamia self-assigned this Dec 31, 2016
@Zizzamia Zizzamia added this to the Version 0.7.1 milestone Dec 31, 2016
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

3 participants