使用敲除绑定值的条件 [英] using a conditional on a knockout binded value

查看:96
本文介绍了使用敲除绑定值的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在使用基因剔除将一些值集绑定到网格,使用下面的foreach之类的东西.

so i am using knockout to bind some set of values to a grid, using the foreach something like i have below.

<table id="pcc-batch-list" class="table table-striped" >
            <thead>
                <tr>
                    <th>Column 1</th>
                    <th>Column 2</th>
                    <th>Column 3</th>
                    <th>Column 4</th>
                </tr>
            </thead>
            <tbody data-bind="foreach:stuff">
                <tr>
                    <td data-bind="text: Something1"></td>
                    <td data-bind="text: Something2"></td>
                    <td data-bind="text: Something3"></td>
                    <td data-bind="text: Something4"></td>
                </tr>
            </tbody>
        </table>

,我想根据说Something2的实际值有条件地更改显示的文本的颜色.我将如何去做?

and I want to conditionally change the color of the text displayed based on the actual value of say Something2. How would i go about doing that?

推荐答案

尝试CSS绑定 http://knockoutjs.com/documentation/css-binding.html 请记住在表达式中使用().

Try css binding http://knockoutjs.com/documentation/css-binding.html remember to use () in expression.

data-bind="text: Something1, css: {colorClass: isSomething() > 0}"

这篇关于使用敲除绑定值的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆