Thanks everyone. This is what I eventually did, with help from lots of the answers and comments.
<script type="text/html" id="fkeyByName-template">
<select data-bind="optionsCaption: 'Choose...',
optionsText: function(item){ return item.value.name;},
optionsValue: function(item){ return item.id;},
valueAllowUnset: true,
options: (function(){return $root.foreignKeys.values(col.ftype);})(),
value: value,
optionsAfterRender:function(option,item){
$root.setOptionDisable(option,item,value,$element,$data);
}
">
</select>
{{! <p data-bind="text: value"></p> }}
</script>
<script type="text/javascript">
model.setOptionDisable = function (option, item, value, select, data) {
if (item) {
ko.applyBindingsToNode(option, {disable: item.value.removed}, item);
if (value() == item.id) {
ko.applyBindingsToNode( select,{css: {disabledSelected: item.value.removed}}, data);
}
select.onchange = function() {
ko.applyBindingsToNode( select,{css: {disabledSelected: false}}, data);
};
}
}
</script>
<style>
select option:disabled, select.disabledSelected
{
color: red;
}
/*reset color for options*/
select option:not(:disabled)
{
color:initial;
}
</style>