We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to pass the parameter to the Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

118841 Apr 14,2015 08:59 PM Apr 20,2015 01:58 AM ASP.NET MVC 9
loading
Tags: Grid
minh
Asked On April 14, 2015 08:59 PM

I want to pass parameters to the action method which is in charge of getting data for the grid(like BatchDataSource). How do I do that?

minh
Replied On April 14, 2015 09:45 PM

It seems like it's QueryParam so what assembly stores this QueryParam. How do I get this extension method and how I use it?
Thanks

Alan Sangeeth S [Syncfusion]
Replied On April 15, 2015 04:38 AM

Hi Minh,
Thanks for using Syncfusion products.
Query 1: “pass parameter to action method that fetch data for Grid”
We are glad to let you know that your requirement can be achieved by using “Query” property of Grid. Please refer the following code snippets.

@(Html.EJ().Grid<object>("Grid")

...

.Query("new ej.Query().addParams('empID',2)") // addding extra paramater using 'addParams'

)


For your convenience we have created a sample and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/forum/118841/EJGrid1467055930.zip
Please refer the following documentation for further reference on Query
http://help.syncfusion.com/ug/js/Documents/query.htm
Query 2: “what assembly stores this QueryParam”
For your information “QueryParam” api which belongs to classic Grid. Please refer the following code snippets to find the difference between classic Grid and new Grid Control.

@(Html.EJ().Grid<object>("Grid") //New Grid


@(Html.Syncfusion().Grid<Order>( //Classic Grid


So if your requirement is regarding classic Grid control then please get back to us so that we could provide you a response as early as possible. Please find the difference bet
Note: We have provided the above sample in Query 1 with the new Grid control
Please let us know if you need any further assistance.
Regards,
Alan Sangeeth S

minh
Replied On April 15, 2015 01:00 PM

The sample you gave me is not working.

Alan Sangeeth S [Syncfusion]
Replied On April 16, 2015 03:32 AM

Hi Minh,
Thanks for the update.
The sample we provided is working fine in our end. Could you please check the sample again and let us know what issue you are facing while running the sample so that we could provide you a response as early as possible?

Also please confirm whether you using Classic Grid or new Grid. Please refer the following code snippets to find the difference between classic Grid and new Grid Control.

@(Html.EJ().Grid<object>("Grid") //New Grid


@(Html.Syncfusion().Grid( //Classic Grid



If you are using Classic Grid, then the sample we provided might not work in your end as we had created that sample with new Grid control.
Please let us know if you have any queries.
Regards,
Alan Sangeeth S

minh
Replied On April 16, 2015 10:14 AM

It's working. That's my mistake. Sorry about that

minh
Replied On April 16, 2015 01:37 PM

I use this syntax to pass an integer variable to action method
@{
int AtdId = 50;
}
.Query("new ej.Query().addParams('Id', 'AtdId')")

Or 
.Query("new ej.Query().addParams('Id', AtdId)")
I always get Null value for action method and it does not work for second case.
If I pass parameters like this:

.Query("new ej.Query().addParams('Id', 50)")
It will work.
So how can I pass variable to server side action method? Very frustrating


Alan Sangeeth S [Syncfusion]
Replied On April 17, 2015 06:17 AM

Hi Minh,
Thanks for the update.
We have analyzed your code snippets and found that you have just simply given the variable “AtdId” as a string in Grid property “Query” in Grid property which is the cause of the issue. We suggest you to use the following code snippets to use variable inside string.

@{


int AtdId = 2;


}

@(Html.EJ().Grid<object>("Grid")

.Query("new ej.Query().addParams('empID',"+AtdId+")")

...

)


Also for your information, when we pass integer value then the parameter in server-side action should be of integer type and if we pass string to integer then null exception would occur.
For your convenience we have modified the sample based on your requirement and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/forum/118841/EJGrid-542044981.zip
Please let us know if you need any further assistance.
Regards,
Alan Sangeeth S

minh
Replied On April 17, 2015 12:56 PM

Thanks a lot. It would been great if I can found this on documentation!

Alan Sangeeth S [Syncfusion]
Replied On April 20, 2015 01:58 AM

Hi Minh,
Thanks for the update.
We have considered your suggestion and we will add this in our Grid documentation.
Please let us know if you have any queries.
Regards,
Alan Sangeeth S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;