首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何根据数据标准在标准网格中更改行颜色?

如何根据数据标准在标准网格中更改行颜色?
EN

Stack Overflow用户
提问于 2022-01-24 20:48:04
回答 1查看 135关注 0票数 0

在这种情况下,我希望网格行是特定的颜色,这是根据该行中的某个字段设置的。

我看过这个案子:

How can we set color for particular column filed value conditionally in Acumatica

也是在这里:

http://asiablog.acumatica.com/2016/12/using-colors-in-acumatica.html

在某种程度上起作用了。不幸的是,它只在单击其中一行时更改颜色,而不是在加载屏幕或更新字段和单击保存时更改颜色。当页面刷新或保存发生时,事件"grid_RowDataBound“不触发吗?

底线:在刷新屏幕或更新/保存字段时,如何设置行颜色?

如果用户必须单击其中一行才能实现此功能,则没有多大用处。

谢谢..。

EN

回答 1

Stack Overflow用户

发布于 2022-01-25 01:46:10

将javascript方法放在PXDataSource aspx控件下更好:

代码语言:javascript
复制
<px:PXDataSource>
    <ClientEvents Initialize="HighlightLines" CommandPerformed="HighlightLines"/>
</px:PXDataSource>

<script type="text/javascript">
        function HighlightLines ()
        {
            if(px_all && px_all["ctl00_phG_grid <=the html ID of the grid"] && px_all["ctl00_phG_grid"].rows)
            {
                let lines = px_all["ctl00_phG_grid"].rows.items;
                for(let i=0;i<lines.length;i++)
                {
                    let currentLine=lines[i];
                    if(currentLine.getCell("DAC__Field").getValue() == 'SomeValue')
                    {
                        currentLine.style = 'background-color: green';
                        currentLine.repaint();
                    }
                    else if (currentLine.getCell("DAC__Field").getValue() == 'SomeOtherValue')
                    {
                        currentLine.style = 'background-color: yellow';
                        currentLine.repaint();
                    }
                    else if (currentLine.getCell("NGSampleTest__Test").getValue() == 'PGTAND')
                    {
                        currentLine.style = 'background-color: red';
                        currentLine.repaint();
                    }
                }
            }
        }
    </script>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70840294

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档