- Home
- Forum
- ASP.NET MVC
- How to pass the parameter to the Grid
How to pass the parameter to the Grid
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?
SIGN IN To post a reply.
9 Replies
MI
minh
April 15, 2015 01:45 AM UTC
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
AS
Alan Sangeeth S
Syncfusion Team
April 15, 2015 08:38 AM UTC
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.
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.
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
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
MI
minh
April 15, 2015 05:00 PM UTC
The sample you gave me is not working.
AS
Alan Sangeeth S
Syncfusion Team
April 16, 2015 07:32 AM UTC
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?
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
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
MI
minh
April 16, 2015 02:14 PM UTC
It's working. That's my mistake. Sorry about that
MI
minh
April 16, 2015 05:37 PM UTC
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
AS
Alan Sangeeth S
Syncfusion Team
April 17, 2015 10:17 AM UTC
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.
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
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
MI
minh
April 17, 2015 04:56 PM UTC
Thanks a lot. It would been great if I can found this on documentation!
AS
Alan Sangeeth S
Syncfusion Team
April 20, 2015 05:58 AM UTC
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
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
SIGN IN To post a reply.
- 9 Replies
- 2 Participants
-
MI minh
- Apr 15, 2015 12:59 AM UTC
- Apr 20, 2015 05:58 AM UTC