Tried that - no luck.
As i can see there is data in $scope.mydata - but renderedRows is emplty
array [] - in internal json structure for nggrid - not sure why...
On Monday, June 23, 2014 12:39:43 AM UTC-5, Gordon Bockus wrote:
>
> I'd guess that the success handler for the post isn't in the correct js
> scope. If you set a var me = $scope; prior to the $http call then use
> me.myData = data in the success handler you'll be in business. I would
> also suggest that your move the http call to a service. Doing it like you
> have it makes it more difficult to test.
>
> Gordon
>
> On Sunday, June 22, 2014 2:38:28 AM UTC-5, nathan wrote:
>>
>> This is regarding nggrid not displaying data after the REST call.
>>
>> When i use the $http post() and the success callback - In chrome debug
>> window i can see that rest call is successful and json is logged on the
>> console and there are no other errors in the console - but still no data is
>> displayed on the grid/ui. There seems to be some problem in $http.post() -
>> (Even if i hardcode the $scope.myData in the success() method i am unable
>> to see the data populated on the grid/ui). I have debugged in chrome and
>> found that there is correct data in $scope.mydata.
>>
>> If I hardcode the data in $scope.myData before the $http.post() call - i
>> see the nggrid/ui populated and working fine. So there is no problem on the
>> JSON or ng-grid data and columnDefs.
>>
>> i inspected the $scope using ng-inspector /batarang plugin and there is
>> data in $scope.mydata. However renderedRows in nggrid internal structure is
>> empty array - not sure why ??
>>
>> Can the experts pls weigh in - thanks. I have trimmed the some of the
>> code below....
>>
>> function (controllers) {
>> controllers.controller('nggridcontroller',
>> [ '$scope',
>> 'RFLeftGridSummaryServicefunc', '$http',
>> function ($scope, RFLeftGridSummaryServicefunc1, $http) {
>> // WORKS GOOD IF I HARDCODE this JSON in the $scope here
>> outside the http call
>> // $scope.myData =
>> [{"login":"kDavid1","propertyid":128105,"scenarioname":"Property History
>> Default","year":"2014"............
>>
>> var jsonString = '{"properties":[2323,2245]}';
>> $http({method: 'POST',
>> url:
>> '/ysconfig/rf/properties/summary/?scenarioCreator=kDavid&scenarioName=budgetscenerio',
>> data: jsonString}).success(function (data) {
>> console.log('success ');
>> console.log(JSON.stringify(data)); // DISPLAYS THE
>> DATA FROM REST CALL
>> $scope.myData = data;
>> // DOES not work EVEN if I HARDCODE the working JSON
>> in scope
>> //$scope.myData =
>> [{"login":"kDavid1","propertyid":128105,"scenarioname":"Property History
>> Default","year":"2014"......
>> }).error(function (data) {
>> console.log('error ');
>> });
>>
>> // NG-GRID JSON
>> $scope.gridOptionsFromController = {
>> // here is data from scope
>> data: 'myData',
>> columnDefs: [
>> {field: 'year', displayName:
>> 'Year-fromController'},
>> {field: 'occupancy', displayName: 'Occ'} ,
>> {field: 'rent', displayName: 'Rent'} ,
>> {field: 'revenue', width: '90', cellFilter:
>> 'currency', displayName: 'Rev'}
>> ]............
>>
>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.