【问题标题】:Kendo grid php function in template模板中的剑道网格php函数
【发布时间】:2023-03-09 06:13:01
【问题描述】:

我正在使用带有 PHP Wrapper 的剑道网格 ... 格式化我的列时,我使用模板,但我无法将 #: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);

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

【问题讨论】:

  • 嗯! PHP 在服务器上运行。模板在浏览器中展开。你正在混合双方。请重新提出您要实施的问题,希望我们能帮助您。

标签: php function grid kendo-ui var


【解决方案1】:

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

<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多