Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reporting services 按列中的数字交替行颜色_Reporting Services - Fatal编程技术网

Reporting services 按列中的数字交替行颜色

Reporting services 按列中的数字交替行颜色,reporting-services,Reporting Services,我有一个列,列中的数字决定作业和后缀: 例如: |Jobnumber|Suffix| x001 1 - white x001 2 - grey x001 2 - grey x001 3 - white x002 1 <---- where it would break the alternating color, Should be grey! x002 1 - should be grey

我有一个列,列中的数字决定作业和后缀:

例如:

|Jobnumber|Suffix| 
  x001       1 - white
  x001       2 - grey
  x001       2 - grey
  x001       3 - white
  x002       1  <---- where it would break the alternating color, Should be grey!
  x002       1 - should be grey
  x002       1 - should be grey
  x002       2 - should be white
  x002       2 - should be white
  x003       1 - should be grey
|作业编号|后缀|
x001 1-白色
x001 2-灰色
x001 2-灰色
x001 3-白色

x002 1如果希望交替的行颜色忽略jobnumber和后缀,则将表达式基于ROWNUMBER而不是后缀

e、 g.
=IIF(行号(无)模式2,“浅蓝色”,无)

更新:基于修订后的问题

也许有一种更优雅的方法可以做到这一点,但下面的方法应该可以奏效

要做的第一件事是转到报表属性并向报表中添加两个报表变量。添加值为
1的
AltBackColor
和值为
-1的
LastRownumber
。关闭只读复选框

接下来,单击“代码”选项卡添加以下函数

Public Function BackColour (ByVal cuRowNumber AS Integer, ByVal lastJobNumber AS String, ByVal curJobNumber AS String, ByVal lastSuffix AS Integer, ByVal curSuffix AS Integer) as Integer
' Check if EITHER the job or suffix have changed, if so, switch the backcolour flag and update the report variable.

Dim switch as boolean
switch = ((lastJobNumber <> curJobNumber) or (lastSuffix <> curSuffix)) and cuRowNumber <> Report.Variables!LastRowNumber.Value

If Switch = true THEN 
    IF Report.Variables!AltBackColour.Value = 0 THEN 
        Report.Variables!AltBackColour.Value = 1 
    ELSE Report.Variables!AltBackColour.Value = 0
    END IF
End if

Report.Variables!LastRowNumber.Value = cuRowNumber

BackColour = Report.Variables!AltBackColour.Value 

End Function
我用你的样本数据做了这个,得到了以下结果


基本上,代码检查后缀的工作是否已更改,并在1和0之间切换标志以指示使用哪种颜色。它还检查我们是否没有像以前一样检查同一行。我们这样做是因为即使我们设置了行的backcolor属性,实际发生的情况是每个单元格都得到backcolor属性集,这意味着每个单元格都会调用代码,并且会不断翻转标志。通过检查行是否已更改,我们可以绕过此问题。

我希望交替颜色由后缀指示,但该范围内的下一组工作编号也有与其相关的后缀,这就是交替行颜色中断的地方。就像在我最初的帖子中,作业编号x001以后缀“3”结尾,然后作业编号x002在范围内出现,后缀被重新排序回1,这就是它中断的地方。我不确定我是否理解。你的意思是第一行会高亮显示,但第二行和第三行不会,然后第四行会高亮显示,等等?你可以编辑你的问题并显示每行数据的颜色,这样就清楚了。我修复了一个例子,如果你看它,箭头是交替颜色,当工作编号更改时,后缀不会分开。我正要处理一些类似的自定义代码,但你似乎已经首先确定了它。如果你能简单地访问
以前的(Fields!Suffix.BackgroundColor)
会容易得多,但我认为你的更新是最好的方法。是的,我相信有更好的方法来做这件事,但这是我在决定这个方法之前兜了一圈。我不知道;这些天我没有足够的脑力。。。
=IIF(
    Code.BackColour(
                    RowNumber(Nothing)
                    , Previous(Fields!JobNumber.Value)
                    , Fields!JobNumber.Value
                    , Previous(Fields!Suffix.Value)
                    , Fields!Suffix.Value
                    ) = 0
    , Nothing
    , "LightGreen"
    )