【问题标题】:Changing the colour of row in table Oracle Jet更改表 Oracle Jet 中的行颜色
【发布时间】:2017-04-24 06:42:50
【问题描述】:

我正在使用 Oracle Jet 和 PHP 来设计一个网站。这里按类型划分我想改变每一行的颜色。任何人都可以帮助如何使用自定义行模板动态更改每行的颜色

<div id="pagingControlfsa">
    <table id="table" summary="Activity List" aria-label="Activity"
           data-bind="ojComponent: {component: 'ojTable', data: pagingDatasource, columns:
            [{headerText: 'Remove', id: 'column1', sortable: 'disabled'},
             {headerText: 'ID', field: 'activityid'},
             {headerText: 'Activity Type', field: 'activityname'},
             {headerText: 'Status', field: 'status'},
            {headerText: 'Action', id: 'column2', sortable: 'disabled'}],
             rowTemplate: 'row_tmpl',
             rootAttributes: {'style':'width: 100%;'}}">
    </table>
    <div id="paging" data-bind="ojComponent: {component: 'ojPagingControl', data: pagingDatasource, pageSize: 15}">
    </div>
</div>
<br/>
<br/>
<script type="text/html" id="row_tmpl">    
    <tr>
        <td><input type="checkbox" data-bind="attr: {id: activityid}"/></td>
        <td><div id='actId' data-bind="text: activityid"></div></td>
        <td><div id="Resource" data-bind="text: name"></div></td>
        <td><div id="statusact" data-bind="text: status"></div></td> 
         <td><div id="modify_div" data-bind="click:function(data,event){ $parent.editRecord(activityid,data,event)}">Modify</div></td>
    </tr>
</script>

【问题讨论】:

    标签: oracle-jet


    【解决方案1】:

    您可以使用淘汰赛样式绑定来执行此操作。您可能需要将此添加到行模板中的每个 td 元素,以便为行中的每个单元格着色:

            <td><div data-bind="text: activityid, style: {'background-color': activityname = 'Foo' ? 'green' : 'red'}"></div></td>
    

    淘汰赛documentation 有很好的样式绑定信息。如果您愿意走那条路,它们也有一个 css 绑定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-12
      • 1970-01-01
      • 1970-01-01
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-22
      相关资源
      最近更新 更多