javascript - how to show data from json to ui-grid in angular ui-grid -


i getting json django , want show in angular ui-grid getting error:

error: coldef.name or coldef.field property required preprocesscoldef@http://127.0.0.1:8000/static/buddy/js/ui-grid.js:3771:1 buildcolumns/<@http://127.0.0.1:8000/static/buddy/js/ui-grid.js:3630:7 buildcolumns@http://127.0.0.1:8000/static/buddy/js/ui-grid.js:3629:5 datawatchfunction@http://127.0.0.1:8000/static/buddy/js/ui-grid.js:2749:27 $watchcollectionaction@http://127.0.0.1:8000/static/buddy/js/angular.js:15693:13 $rootscopeprovider/this.$get</scope.prototype.$digest@http://127.0.0.1:8000/static/buddy/js/angular.js:15826:23 $rootscopeprovider/this.$get</scope.prototype.$apply@http://127.0.0.1:8000/static/buddy/js/angular.js:16097:13 done@http://127.0.0.1:8000/static/buddy/js/angular.js:10546:36 completerequest@http://127.0.0.1:8000/static/buddy/js/angular.js:10744:7 requestloaded@http://127.0.0.1:8000/static/buddy/js/angular.js:10685:1 

i want show attributes "fields"

the json is:

[{"fields": {"joiningtime": null, "boozprofileid": 1, "userid": 1, "likestatus": true}, "model": "buddy.guestentry", "pk": 1}, {"fields": {"joiningtime": null, "boozprofileid": 1, "userid": 1, "likestatus": true}, "model": "buddy.guestentry", "pk": 2}, {"fields": {"joiningtime": "2015-10-18t15:53:58.243z", "boozprofileid": 12, "userid": 3, "likestatus": true}, "model": "buddy.guestentry", "pk": 3}, {"fields": {"joiningtime": "2015-10-18t15:54:24.055z", "boozprofileid": 8, "userid": 3, "likestatus": true}, "model": "buddy.guestentry", "pk": 4}, {"fields": {"joiningtime": null, "boozprofileid": 3, "userid": 1, "likestatus": true}, "model": "buddy.guestentry", "pk": 5}, {"fields": {"joiningtime": null, "boozprofileid": 3, "userid": 1, "likestatus": true}, "model": "buddy.guestentry", "pk": 6}, {"fields": {"joiningtime": null, "boozprofileid": 3, "userid": 1, "likestatus": true}, "model": "buddy.guestentry", "pk": 7}, {"fields": {"joiningtime": null, "boozprofileid": 3, "userid": 1, "likestatus": true}, "model": "buddy.guestentry", "pk": 8}] 

the error receive indicates not have defined column definitions ui grid, or perhaps not have defined them properly. refer nested fields attributes fields.<attributename> :

//the json above  $scope.gridoptions.data = [{"fields": {"joiningtime": null, "boozprofileid": ....}];  $scope.gridoptions.columndefs = [    {name: 'fields.joiningtime' },     {name: 'fields.boozprofileid' },     {name: 'fields.userid' },    {name: 'fields.likestatus' }  ]; 

demo -> http://plnkr.co/edit/kxves4g64rvwnefbzzv2?p=preview


remember target right controller. have both indexctrl , ajax :

<div ng-controller="ajax">    <div ui-grid="gridoptions" ui-grid-cellnav class="grid"></div> </div> 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -