Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can change id and name columns #34

Open
Sandhya-Deshmukh opened this issue Dec 19, 2019 · 2 comments
Open

Can change id and name columns #34

Sandhya-Deshmukh opened this issue Dec 19, 2019 · 2 comments

Comments

@Sandhya-Deshmukh
Copy link

is it possible to change id and name of data (json array)?

@Sandhya-Deshmukh
Copy link
Author

convert JSON array from one structure to desired structure, using

var data = receivedObject.map(function(item) {
       return {
         id: item.UserID,
         name: item.FullName + " - " + item.Mobile
       };
     });

     setResults(data);

@Amol-B-Patil
Copy link

This data will return only the id and name and other params in the list will not be retrieved. The easiest way to get the whole item back in onItemSelect callback is -

` var indianStates = [
{
stateId: 1,
stateName: "Maharashtra"
},
.
.
.
{
stateId: 9,
stateName: "Gujrat"
},
{
stateId: 10,
stateName: "Punjab"
}
];

useEffect(() => {
indianStates.forEach((item, index, array) => {
item.name = item.stateName;
item.id = item.stateId;
});
}, []); `

This will give you the whole item back to the onItemSelect callback method and you easily you can render this in the dropdown.

Hope it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants