angularjs:如何在kendo模板中设置kendo颜色选择器的值?

时间:2015-11-06 09:15:00

标签: javascript angularjs kendo-ui kendo-template

我的kendo网格有以下rowTemplate:

<script id="gridTemplate" type="text/x-kendo-template">
<tr data-uid="#= uid #">
    <td>
        <input type="color" kendo-color-picker k-palette="controller.colors" value="'#=color#'" on-change="controller.changeColor()" />
    </td>
</tr>

我的问题是我想从dataItem.color属性设置颜色选择器的值。使用上面的语法,我收到以下消息: The specified value "'#0000ff'" does not conform to the required format. The format is "#rrggbb" where rr, gg, bb are two-digit hexadecimal numbers.

如果我将其更改为value="#=color#"(没有单引号),那么我得到:

Error: [$parse:lexerr] Lexer Error: Unexpected next character  at columns 0-    0 [#] in expression [#00ff00].
http://errors.angularjs.org/1.4.0/$parse/lexerr?p0=Unexpected%20next%20character%20&p1=s%200-0%20%5B%23%5D&p2=%2300ff00
Cause: <input type="color" kendo-color-picker="" k-palette="trend.colors" value="#00ff00" on-change="trend.changeColor()">
{anonymous}()@columns 0-0 [#] in expression [#00ff00].
{anonymous}() (http://errors.angularjs.org/1.4.0/)$parse/lexerr?p0=Unexpected%20next%20character%20&p1=s%200-0%20%5B%23%5D&p2=%2300ff00

我尝试在角度代码中移动模板并使用function(dataItem)但导致相同的错误。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

尝试设置“值”字段时,我收到了同样的错误。相反,我尝试设置代表调色板的视图模型/ $ scope属性。

Kendo颜色选择器控件

 public interface ICustomerProcessingUnit
 {
    Task ProcessAsync();
 }

    public abstract class CustomerProcessingUnitBase : ICustomerProcessingUnit
    {
        public abstract Task ProcessAsync();

        public void Process()
        {
            this.ProcessAsync().Wait();
        }
    }

在控制器的加载事件中,将调色板的属性设置为

        <input kendo-color-picker ng-model="dashboardBuilder.templateOptions.titleBackgroundColor" k-palette="'websafe'" k-preview="false" k-input="true" k-opacity="true"/>

这会将您的选择器默认为您选择的颜色。