javascript - Angular JS replace values ng grid -
i newbie in angular js , think need help.
this issue : have ng-grid linked table. within there values , id (which foreignkey table). don't want show id field in foreign table.
companyfactory.getcompanies().success(function (data) { $scope.objs = info }) $scope.gridoptions = { data: 'objs', showgrouppanel: true, jqueryuidraggable: true, columndefs: [ { field: 'comp_name', displayname: 'comp_name'}, { field: 'country', displayname: 'country' }, { field: 'lu_sector_id', displayname: 'sector', }, ] }; i want show sector_name field instead of sector_id field. how can create relation between these 2 tables ?
$scope.countries = [ { comp_name: 'koli', country: 'koli_country', lu_sector_id: '1'}, { comp_name: 'zoli', country: 'zoli_country', lu_sector_id: '2'}, { comp_name: 'tuli', country: 'tuli_country', lu_sector_id: '3'}, ]; $scope.sector= [ { lu_sector_id: '1', lu_sector_name: 'sector_1'}, { lu_sector_id: '2', lu_sector_name: 'sector_2'}, { lu_sector_id: '3', lu_sector_name: 'sector_3'}, ]; i show in ng-grid sector name instead of sector_id.
it hard reply question without info of data object.
however, suppose data object returned companyfactory like:
[ { "comp_name": "tomms", "country": "france", "lu_sector_id": "9":, "sector": { "sector_name": "it" } } ] you need bind right field:
$scope.gridoptions = { data: 'objs', showgrouppanel: true, jqueryuidraggable: true, columndefs: [ { field: 'comp_name', displayname: 'comp_name'}, { field: 'country', displayname: 'country' }, // here { field: 'sector.sector_name', displayname: 'sector', }, ] }; but, if returning both objects separated need link manually. suggestion perform in server side , homecoming object used example.
javascript angularjs ng-grid
No comments:
Post a Comment