javascript - Need to render data column by column using ng-grid in Angular JS -


i have data in below format,

$scope.mystudentdata = {"moroni":{"id":"1","grade":"a"},"tiancum":{"id":"2","grade":"b"}} 

but expected grid is,

$scope.mygridoptions = [{"details":"id", "moroni":"1", "tiancum":"2"},{"details":"grade", "moroni":"a", "tiancum":"b"}]; 

this because ng-grid-options expects rows. there way can make grid column-wise? note: want use angular two-way binding between derived fields , hence, not transforming data format expected grid.

you can actually.

$scope.gridoptions = {         data: users,         columndefs: [             {field: 'id', displayname: 'member id'},             {field: 'lastname', displayname: 'last name'},             {field: 'firstname', displayname: 'first name'},             {field: 'email', displayname: 'email'},             {field: 'phone', displayname: 'phone'}      }; 

and

<div ui-grid="gridoptions"></div> 

where users array of objects , column definitions columns want display. field property must match fields in objects.

the api of gridoptions can found here.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -