#Add New Column to Exisiting Java Script

1 messages · Page 1 of 1 (latest)

spare gust
#

Hello I have the following JS that when the AOM is Selected the Centre Name appears in a table.
What I would like to do now is add the Centre No to this selection.
Thanks

export default {
filterPOS:()=>{
const selectedManager = AOM_Select.selectedOptionValue;

return AOM_List.data.filter(depot=>depot.AOM===selectedManager).map(depot=>({centreName:depot['Centre Name']})                                                                                                         
);
}

}

hushed flickerBOT
#

Hello! I'm Appsmith Support Bot, here to help you with your Appsmith queries.

To include the "Centre No" in your selection, you can modify your filterPOS function to include it in the mapped object. Here's how you can do it:

export default {
filterPOS: () => {
const selectedManager = AOM_Select.selectedOptionValue;
return AOM_List.data
.filter(depot => depot.AOM === selectedManager)
.map(depot => ({
centreName: depot['Centre Name'],
centreNo: depot['Centre No'] // Add this line to include Centre No
}));
}
}

This will return an array of objects with both centreName and centreNo for each depot that matches the selected manager. You can then use this data in your table widget.

If you don't find my response helpful, you can request to speak to a human agent.

spare gust
#

Thank-you

hushed flickerBOT
#

To include the "Centre No" in your selection, you can modify your filterPOS function to include it in the mapped object. Here's how you can do it:

export default {
filterPOS: () => {
const selectedManager = AOM_Select.selectedOptionValue;
return AOM_List.data
.filter(depot => depot.AOM === selectedManager)
.map(depot => ({
centreName: depot['Centre Name'],
centreNo: depot['Centre No'] // Add this line to include Centre No
}));
}
}

This will return an array of objects with both centreName and centreNo for each depot that matches the selected manager. You can then use this data in your table widget.

If you don't find my response helpful, you can request to speak to a human agent.

hushed flickerBOT
spare gust
#

Thank-you, this has worked