none
Column visibility based on multivalue parameter selection RRS feed

  • Question

  • Hi All,

    I'm trying to set a column to be visible only when one or two values of a multivalue parameter are chosen, the values are integer **Corrected to String**.

    I'd rather naively thought something like this might work  "=IIF(Parameters!pCASE_TYPE_ID.Value IN (2,4), True, False)"  but sadly it didn't

    Could someone point me in the right direction

    Kind regards
    Dan
    Monday, October 13, 2008 10:09 AM

Answers

  • Hello Dan,

    now i carefully read your first Entry again.(didn't notice: '...set a column to be visible...'. My Mistake ) :-(

    You have to change the return value of the function:

    Public Function giveHidden(ByVal values() As object) As boolean
       for each value as string in values
            if value = "4" then return False
       next
    return True
    End Function


    This is for the RS2000 Version and the Property is 'Hidden'. If the "4" is choosen, the function gives you a false.




    BanditTreiber

    Germany, NRW
    • Marked as answer by danbridgland Tuesday, October 14, 2008 8:44 AM
    Tuesday, October 14, 2008 5:17 AM

All replies

  • Hello dan,

    you have to make Usercode:


    Public Function giveHidden(ByVal values() As object) As boolean
       for each value as integer in values
            if value = 2 or value = 4 then return true
       next
    return false
    End Function


    In the Hidden-Property: 

    =code.giveHidden(Parameters!pCASE_TYPE_ID.Value)




    HTH,

    BanditTreiber


    Germany, NRW
    Monday, October 13, 2008 10:42 AM
  • Hi BanditTreiber

    I've followed your example, I've added the function to the report's custom code, but I still can't get it to work.   In the visibility expression, the function name 'giveHidden' gives an error 'Unrecognized identifier'

    the report still runs, without error, but the column is always visible.

    Regards
    Dan
    Monday, October 13, 2008 12:47 PM
  • Hello dan,

    dont forget the = in the Hidden-Property.
    Do you have copy and paste?


    =code.giveHidden(Parameters!pCASE_TYPE_ID.Value)


    For me, it works.


    BanditTreiber
    Germany, NRW
    Monday, October 13, 2008 1:01 PM
  • I've just checked and re-checked everything, then I spotted the data type of the parameter is actually text, not integer.

    How would I change the functions code?

    Sorry for the mix up

    Regards
    Dan
    Monday, October 13, 2008 1:11 PM
  • Hello Dan,


    try this:


    Public Function giveHidden(ByVal values() As object) As boolean
       for each value as string in values
            if value = "2" or value = "4" then return true
       next
    return false
    End Function



    BanditTreiber
    Germany, NRW
    Monday, October 13, 2008 1:31 PM
  • Hi BanditTreiber,

    I've amended the code, but its still not working, Does this code function with a multivalue parameter?  My understanding of the parameter is that once the selection is made the values of the selections of the parameter are converted to a comma separated string.  Does this function handle the string as a comma separated value?

    Regards
    Dan
    Monday, October 13, 2008 1:52 PM
  • Hi Dan,

    i testet it with a multivalue parameter. The Funtion get an array of objects:

        Public Function giveHidden(ByVal values() As object) As boolean


    In the Function you test the values in the array until the first true condition/term :

        for each value as integer in values
            if value = 2 or value = 4 then return true
        next




    BanditTreiber



    PS.: I try to give more support tomorrow
    Germany, NRW
    Monday, October 13, 2008 2:04 PM
  • I've managed to hide the column with the following code.

    Public Function giveHidden(ByVal values() As object) As boolean
       for each value as string in values
            if value <> "4" then return TRUE
       next
    return false
    End Function

    When there are multiple values selected including and/or excluding "4" the column remains hidden.   When the selected parameter value is only 4 the column is visible

    I need the column to to visible at all time when 4 is selected

    Regards
    Dan

    Monday, October 13, 2008 3:47 PM
  • Hello Dan,

    I'am now at home and i can't test anything.


    Do you have RS 2008?? And the property really called 'Visible', then you have to make:

    Public Function giveHidden(ByVal values() As object) As boolean
       for each value as string in values
            if value = "4" then return TRUE
       next
    return false
    End Function

    I am Confused now a liitle bit. :-)
    In RS 2005 the property is called 'Hidden'.



    We fix it tomorrow.


    BanditTreiber
    Germany, NRW
    Monday, October 13, 2008 4:12 PM
  • Hello Dan,

    now i carefully read your first Entry again.(didn't notice: '...set a column to be visible...'. My Mistake ) :-(

    You have to change the return value of the function:

    Public Function giveHidden(ByVal values() As object) As boolean
       for each value as string in values
            if value = "4" then return False
       next
    return True
    End Function


    This is for the RS2000 Version and the Property is 'Hidden'. If the "4" is choosen, the function gives you a false.




    BanditTreiber

    Germany, NRW
    • Marked as answer by danbridgland Tuesday, October 14, 2008 8:44 AM
    Tuesday, October 14, 2008 5:17 AM
  • Hi BanditTreiber

    That now works perfectly.   Thank you very much.  I guess if I had applied a little thought to it, perhaps even tried to read the code, I might have worked that out myself.   good thing there are people like you willing to help others in need.

    Thanks again

    Regards
    Dan 
    Tuesday, October 14, 2008 8:42 AM
  •  Hi, just to clarify, Yes, I am using RS2008, Though I'm curious to know how you knew that?  I didn't think the releases differ that much?

    Regards
    Dan
    Tuesday, October 14, 2008 8:44 AM