小编eth*_*han的帖子

angular-ui-grid:如何在鼠标悬停时突出显示行?

我想在鼠标位于其上方时突出显示整行的角度ui网格.

我试图通过添加设置背景颜色的ng-mouseover和ng-mouseleave回调来修改rowTemplate.

这是我的rowTemplate - 我希望前三行将整个行颜色更改为红色.但只有当前鼠标下的单元格才会发生变化.

<div
    ng-mouseover="rowStyle={'background-color': 'red'}; grid.appScope.onRowHover(this);"
    ng-mouseleave="rowStyle={}"
    ng-style="rowStyle"
    ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid"
    ui-grid-one-bind-id-grid="rowRenderIndex + '-' + col.uid + '-cell'"
    class="ui-grid-cell"
    ng-class="{ 'ui-grid-row-header-cell': col.isRowHeader }"
    role="{{col.isRowHeader ? 'rowheader' : 'gridcell'}}"
    ui-grid-cell>
</div>
Run Code Online (Sandbox Code Playgroud)

如何在鼠标悬停事件中突出显示整行?

我尝试的另一种方法:使用一些回调函数执行此操作 - 例如示例中的appScope.onRowHover.在这里,我有行的范围.如何在onRowHover函数中设置该行的样式?

谢谢!

链接到Plunkr.我希望将鼠标悬停在网格单元格上以将整行变为红色.

angularjs angular-ui-grid

10
推荐指数
2
解决办法
2万
查看次数

C++中的隐式转换

在C++中,我试图使用条件运算符进行隐式转换.考虑这个例子:

class MyFloat
{ 
    public:                                                                    
        MyFloat(float val){m_val = val;}
        operator float(){return m_val;}
    protected:
        float m_val;
};

int main(int argc, char **argv)
{
    MyFloat a = 0.5f;
    MyFloat b = 1.0f;                            
    float x = true ? a-0.5f : b;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

它会导致编译器错误:

error: operands to ?: have different types ‘MyFloat’ and ‘float’
Run Code Online (Sandbox Code Playgroud)

我希望条件运算符隐式转换ba-0.5float 类型.但这不会发生.我如何实现这种隐式演员?

理想情况下,我想避免静态强制转换或访问方法float MyFloat::getValue().

c++ casting conditional-operator implicit-conversion

3
推荐指数
1
解决办法
1881
查看次数