【发布时间】:2017-12-04 06:22:33
【问题描述】:
我正在尝试为用户配置一个颜色选择器,以使用数据库中的十六进制字符串调色板从一组颜色中进行选择。除了我无法将值设置为空而未选择颜色外,我一切正常。不考虑 value 属性,将其设置为 null 或空字符串都选择颜色选择器中的第一个选项。有谁知道我如何设置没有选择颜色的值?
我的看法:
@(Html.Kendo().ColorPicker()
.Name("Colour")
.TileSize(32)
.Columns(16)
.Palette(colours)
.Deferred()
)
我的控制器获取数组的方法:
public string[] GetColours()
{
var autoCadColours = _somerService.GetColours();
int length = autoCadColours.Count();
string[] colours = new string[length];
foreach (var i in autoCadColours.Select((value, index) => new { Value = value, Index = index }))
{
colours[i.Index] = i.Value.HexString;
}
return colours;
}
【问题讨论】: