Replace Value in Column with Value from Array
Replace Value in Column with Value from Array

Hello,
I need some food for thought. I have a column with the ID of a supplier. I have the suppliers in an array, up to now I always retrieved this by $lieferant_array[$lieferantId]->value;. How can I implement this in the editor? Because the column now shows the ID and not the name from the array.
I hope I have expressed myself clearly.
Here is the link to the debug: https://debug.datatables.net/iqikad
Thanks
Lars
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Lars,
your link is a 404 ...
Roland
Ah it's not a 404, it's just visible to the site administrators. We'll take a look and report back,
Colin
I should really change that 404 to a 401... Thanks for pointing that out.
@Airprimus - You have:
in your JSON. Is that what you want to show in the column? If so use
columns.data
withdata: 's_articles_supplier.name'
.Allan
Hello, Allan,
no, I mean the column s_articles_attributes.supplier. In this column the supplier ID is loaded from the database. The supplier's ID is not in the database but in an array. The array looks like this:
[{"key":"0","value":" "},{"key":"1","value":"H\u00f6rmann KG"},{"key":"2","value":"GEZE GmbH"},{"key":"3","value":"GEZE Service GmbH"},{"key":"4","value":"Assa Abloy"},{"key":"5","value":"Bircher"},{"key":"6","value":"Dictator"},{"key":"7","value":"dormakaba"},{"key":"8","value":"GfA"},{"key":"9","value":"Hekatron"},{"key":"10","value":"ELKA"},{"key":"11","value":"Marantec"},{"key":"12","value":"CAME"},{"key":"13","value":"Belfox"},{"key":"14","value":"Planet"},{"key":"15","value":"Locinox"},{"key":"16","value":"FAAC"},{"key":"17","value":"Werma"},{"key":"18","value":"BEA"},{"key":"19","value":"Marx"},{"key":"20","value":"Meesenburg"},{"key":"21","value":"WSS"},{"key":"22","value":"esco"},{"key":"23","value":"CTM Berlin"},{"key":"24","value":"Datelsoft"},{"key":"25","value":"D-Secour"},{"key":"26","value":"Safepart"},{"key":"27","value":"Bft"},{"key":"28","value":"Sperling"},{"key":"29","value":"STF"},{"key":"30","value":"Sonepar"},{"key":"31","value":"Zander"}]
I would now like to display the name from the array in the column supplier instead of the ID. Unfortunately I have no idea how to implement this with the Datatables.
Thanks
Lars
Hi Lars,
You would use a renderer. For example you might use:
Assuming your array of suppliers is called
suppliers
- change as required.Allan