Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ng-grid paging
Message
De
25/10/2014 03:25:33
 
 
À
25/10/2014 03:22:23
Information générale
Forum:
Javascript
Catégorie:
Autre
Titre:
Divers
Thread ID:
01609778
Message ID:
01609892
Vues:
35
>>>>>>I found this question https://stackoverflow.com/questions/17529559/angularjs-ng-grid-updating-array-with-splice-doesnt-updates-ui which perhaps is relevant to my case.
>>>>>>
>>>>>>Unfortunately, I can not check if it's relevant or not as we only have ng-grid.min.js in our project. I am not exactly sure where to try implementing the copy solution suggested in the second answer.
>>>>>
>>>>>You could try:
var pagedData = angular.copy(data.slice((page - 1) * pageSize, page * pageSize));
>>>>>
>>>>>
>>>>>>BTW, I posted all the code which I currently have in that controller (aside from the few irrelevant methods). May be you can spot the problem right away.
>>>>
>>>>Ok, weird thing. After I believe that change worked fine, I downloaded the latest ng-grid using nuget. I applied the fix suggested in that thread (I only found one place where this code was called).
>>>>
>>>>It stopped working again :(
>>>>
>>>>I then re-applied your suggested fix which seemed to fix the problem originally. It didn't fix it this time and I again see the same exact problem :(
>>>>
>>>>This is getting extremely frustrating :(
>>>
>>>Can you post the change you made to the grid js ?
>>>(Won't get time to look at it now tho - it's pub time here :-})
>>
>>The fix I made in the version
>>
>>
>>/***********************************************
>>* ng-grid JavaScript Library
>>* Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md 
>>* License: MIT (http://www.opensource.org/licenses/mit-license.php)
>>* Compiled At: 08/04/2014 16:09
>>***********************************************
>>
>>here
>>
>>
>> $scope.$on('$destroy', $scope.$parent.$watch(options.data, dataWatcher, true));
>>
>>I added the last parameter true as suggested in the
>>https://stackoverflow.com/questions/17529559/angularjs-ng-grid-updating-array-with-splice-doesnt-updates-ui
>>
>>This didn't help and re-applying your original fix in SetPagingData also didn't help.
>
>So does using the suggestion to copy slice still work with the unmodified ng-grid.js ?
>
>If it does I'd tend to stick with that. Having ng-grid perform a deep watch is expensive and the mod will mean it will always be creating a copy even in situations where it is unnecessary.
>
>If you do need an app wide solution then maybe an alternative would be to use $watchCollection() instead of $watch() in ng-grid ? I'm no angular expert but I think that would be less expensive. I'm always wary of making changes to libraries like this - all to easy for a change that you make to impact other areas of the app using the same library - and also too likely that another developer updates the version without being aware of the mod.
>
>IAC, if you're trying the ng-grid mod then, since you have a source version, you can debug - check if the watch is firing when you expect, compare newVal/oldVal etc.

UPDATE: Duh. Added a bit to my last post and replied to myself instead of updating :-{
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform