模板中的剑道网格php函数


Kendo grid php function in template

我正在使用带有PHP包装的剑道网格。。。格式化我的列时,我使用模板,但我不能将#:ColmunValue#传递到getColorForValue函数。

<script id="ColumnTemplate" type="text/x-kendo-tmpl">
<div style="background-color: <?php echo ''''.$colors->getColorForValue(#:ColmunValue#); ?   >;">
#:ColmunValue#
</div>
</script>

我尝试了第二种解决方案:

$Column = new 'Kendo'UI'GridColumn();
$Column->field('ColumnName')
->title(' ')
->attributes(' bgcolor = '.getColorForValue(#: Column #) )
->templateId('ColumnTemplate')
->width(55);

但两者都不起作用:(有什么想法吗?

rowTemplate中不应该有任何PHP代码(如果它取决于行的值)。您可以使用客户端表达式和函数,如这里所示。

<script id="ColumnTemplate" type="text/x-kendo-tmpl">
    <div style="background-color: #= someFunction(data.PersonName) #">
             #= PersonName#
     </div>
</script>
<script>
      someFunction(name){
          // some logic here and then return color based on the name
          return "red";
      }
</script>