1. A concise explanation of the problem you're experiencing.
I am trying to change the color of a layer on the fly similar to ArcMAP Table of Content.
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
So, here window.shape_details is an object which contains all the layer information and contextid is HTML name of the layer in UI which is referencing the actual layers.
window.cesiumViewer.dataSources.get(currentDataSourceIndex).fill = Cesium.Color.fromCssColorString(selectedColor);
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
We want to change the color of the layers on the fly in the table of contents.
4. The Cesium version you're using, your operating system and browser.