How pass multivalues param values to report MVC or HTML5?

3 posts, 1 answers
  1. Ahmed Amin
    Ahmed Amin avatar
    34 posts
    Member since:
    Apr 2015

    Posted 29 Apr 2015 Link to this post

    Hi

    I have create my report and it's bind to an SQL stored procedure - it works fine when I was pass single value - but now I need to pass multivlue (ProductID) as example to get report where ProductID in (1,2,3)

    I set the SQL stored procedure to let me get result as i need - but the problem i got is in my report i got err msg in image in attachment

    so please how can i make it work in MVC Project or HTML5 Project i can't find that in demo files examples?

    Thanks a lot ....

    Stored Code:

    @MultiVal NVARCHAR(MAX),
    @qty INT
     
    AS
     
    SELECT ProductID, ProductName, @qty AS stock FROM Products
     
    CROSS APPLY dbo.NumbersTable(1, @qty, 1)
     
    WHERE ProductID IN (SELECT Val FROM dbo.fn_String_To_Table(@MultiVal,',',1))

    fn_String_To_Table FUN :

    ALTER FUNCTION [dbo].[fn_String_To_Table] (
                @String VARCHAR(max), /* input string */
       @Delimeter char(1),   /* delimiter */
       @TrimSpace bit )      /* kill whitespace? */
    RETURNS @Table TABLE ( [Val] VARCHAR(4000) )
    AS
    BEGIN
        DECLARE @Val    VARCHAR(4000)
        WHILE LEN(@String) > 0
        BEGIN
            SET @Val    = LEFT(@String,
                 ISNULL(NULLIF(CHARINDEX(@Delimeter, @String) - 1, -1),
                 LEN(@String)))
            SET @String = SUBSTRING(@String,
                 ISNULL(NULLIF(CHARINDEX(@Delimeter, @String), 0),
                 LEN(@String)) + 1, LEN(@String))
      IF @TrimSpace = 1 Set @Val = LTRIM(RTRIM(@Val))
        INSERT INTO @Table ( [Val] )
            VALUES ( @Val )
        END
        RETURN
    END

  2. Answer
    Stef
    Admin
    Stef avatar
    3050 posts

    Posted 30 Apr 2015 Link to this post

    Hello Ahmed,

    Please check the details provided in Pivot dropdown list. The suggested settings are for stored procedures.

    If you use a select statement directly (not a stored procedure), you can use a multivalued parameter directly. For example:
    Select * from HumanResources.Department
    Where (@SelectedValues Is Null) OR DepartmentID in (@SelectedValues)
    Then you do not need to make any further adjustments on the values passed by the multivalued report parameter.

    Regards,
    Stef
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. DevCraft banner
  4. Ahmed Amin
    Ahmed Amin avatar
    34 posts
    Member since:
    Apr 2015

    Posted 04 May 2015 in reply to Stef Link to this post

    Thanks a lot ....
Back to Top