对于这个模型:
var model = [
{ Color: { Hex: "#5EB95E", Name: "green" },
AvailablePatterns: { SelectedId:"",
Patterns:[{Title:"test1", Id:1},{Title:"test3", Id:2}]}},
{ Color: { Hex: "#FAA732", Name:"orange" },
AvailablePatterns: { SelectedId:"",
Patterns:[{Title:"test2", Id:3},{Title:"test4", Id:4}]}}];
如何在我的单元格中使用字段 Color 和 AvailablePatterns?我尝试使用 $parent.getProperty 方法获取此字段,但它对我不起作用
columnDefs: [
{
field: 'Color',
displayName: 'Color',
cellTemplate: '<span class="status" data-bind="style: { backgroundColor : $parent.getProperty("Color.Hex") }"></span>' +
'<span data-bind="text: $parent.getProperty("Color.Name")"></span>'
},
{
field: 'AvailablePatterns',
displayName: 'Pattern', cellTemplate: "<select class=\"pattern\" \
data-bind=\" options: $parent.getProperty('AvailablePatterns.Patterns'), \
optionsValue: '$parent.getProperty('Id')', \
optionsText: '$parent.getProperty('Title')',\
value: '$parent.getProperty('AvailablePatterns.SelectedId')' \"> \
</select>"
}
]