This is a migrated thread and some comments may be shown as answers.

How pass multivalues param values to report MVC or HTML5?

2 Answers 178 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 2
Ahmed asked on 29 Apr 2015, 09:07 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 30 Apr 2015, 11:37 AM
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.

 
0
Ahmed
Top achievements
Rank 2
answered on 04 May 2015, 09:09 AM
Thanks a lot ....
Tags
General Discussions
Asked by
Ahmed
Top achievements
Rank 2
Answers by
Stef
Telerik team
Ahmed
Top achievements
Rank 2
Share this question
or