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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -