2

enter image description here

In the params.value, I have 3 arrays, of which I need to put the Names in a variable. I try to do through ForEach but I can not do it, what's wrong?

var roles = params.forEach(x => params.value.Name);
return roles;

{"Object":[{"TerritoryId":1,"TerritoryName":"Russia","FirmPieRotationRuleId":1,"FirmPieWorkedYears":0,"FirmPieCoolOff":5,"FirmPieRoles":[{"TeamRoleId":1,"Name":"Engagement Leader","MinCount":1,"MaxCount":1,"SortOrder":0},{"TeamRoleId":2,"Name":"Signing Partner","MinCount":1,"MaxCount":1,"SortOrder":0},{"TeamRoleId":3,"Name":"Engagement Manager","MinCount":1,"MaxCount":1,"SortOrder":0}],"StatutoryPieRotationRuleId":null,"StatutoryPieWorkedYears":null,"StatutoryPieCoolOff":null,"StatutoryPieRoles":[],"NonPieRotationRuleId":null,"NonPieWorkedYears":null,"NonPieCoolOff":null,"NonPieRoles":[]}],"Code":0,"ErrorMessage":null,"Errors":[]}

2 Answers 2

3

Array#forEach doesn't return anything. Try Array#map instead.

var roles = params.map(x => params.value.Name);
Sign up to request clarification or add additional context in comments.

16 Comments

I have error "params.map is not a function" Although I used "import 'rxjs/Rx';"
@ValitskiyDmitriy params variable comes from asynchro request?
No, There is no request as such. This is a table, and it works with a response from the server. For the right speakers, it takes the parts you need
{ headerName: "Roles", field: "FirmPieRoles", editable: true, cellEditorFramework: DropdownEditorComponent, cellEditorParams: { values: RolesDictionary }, cellRenderer: function (params) { var roles = params.map(x => params.value.Name); return roles; } },
@ValitskiyDmitriy Is it Angular? Anyways, what argument you are passing to the cellRenderer function?
|
0

The value is the array. Try this:

var roles = params.value.map(val => val.Name)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.