Hi Shane,
Thanks for using Syncfusion products.
Query 1: I am planning on doing this also onChange event of the dropdown.
We have analyzed your issue and we are unable to reproduce the reported issue.
We have created a sample based on your requirement and the same can be downloaded from the following link.
Sample Link: SampleDemo.zip
In the above sample we have passed the extra parameter to the grid using addParams property in Change event of the dropdown list as follows.
@Html.EJ().DropDownList("selectCar").TargetID("carsList").(ClientSideEvents(e => e.Change("change"))
@(Html.EJ().Grid<object>("Grid") . . . . )
<script type="text/javascript"> function change(args) { if (args.itemId == 1) { var data = ej.DataManager({ url: "/Home/Event", adaptor: "UrlAdaptor" }); $("#Grid").ejGrid({ dataSource: data, query: new ej.Query().addParams("employeeID", 4) }); } } </script> |
Query 2: if I add only query like so
We have analyzed the issue and we suggest you to pass the query in ActionBegin clientside event of the grid for passing the extra parameter at initial load of the grid as follows.
@(Html.EJ().Grid<object>("Grid") .Datasource(d => d.URL("/Home/Event").Adaptor(AdaptorType.UrlAdaptor)) . . . . .ClientSideEvents(eve => { eve.ActionBegin("begin");}) )
<script type="text/javascript">
function begin(args) { this.model.query.addParams("employeeID", 4); } </script> |
Please refer the below screenshot for more clarification.
Please try the sample and let us know if you have any queries.
Regards,
Gowthami V.
.Datasource(ds => ds.URL("Controller/Action").Adaptor(AdaptorType.UrlAdaptor)).ClientSideEvents(eve => { eve.ActionBegin("begin");})
function begin() {
this.model.query.addParams("selectedYear", 2014);
}
Hi Weber,
Thanks for your update.
We have analyzed your requirement and we suspect that you have passed the extra parameter to another grid (parentsGrid) instead of defined grid (Grid). And also you have not defined the dataSource to the grid at initial load .
Please refer the below code snippet that you provided in the previous response.
@(Html.EJ().Grid<object>("Grid") )
function change(args) { $("#patientsGrid").ejGrid({ }); } |
We have analyzed your query and we suspect that you want to load the grid dataSource based on the value selected in the dropdownlist (initially 0 th index). For that we have used the Query property of the grid for passing the extra parameter to the serverside using addParams property of the Query as follows.
Please refer the below code snippet.
@(Html.EJ().Grid<object>("Grid") .Datasource(ds => ds.URL("/Home/Event").Adaptor(AdaptorType.UrlAdaptor)) .Query("ej.Query().addParams('EmployeeID','1')") ) |
In the above snippet we have passed “1” as an extra parameter to the grid at initial load of the grid.
And also we suspect that you want to change the datasource of the grid based on the selected value from the dropdownlist. For that we have passed the selected value as an extra parameter to the serverside in change event of the dropdownlist.
Please refer the below code snippet.
function change(args) { $("#Grid").ejGrid({ dataSource: data, query: new ej.Query().addParams("employeeID",obj.selectedTextValue) });} |
For your convenience we have created a sample and the same can be downloaded from the below link.
Sample Link: addparamsissue.zip
And also you have passed the query in both Change event and ActionBegin event and so the Key passed in the query was conflicted with each other. So that only the reported error occurred in the second query.
If we misunderstood your requirement please provide following details to reproduce the issue.
1. Please share in which scenario you want to pass the extra parameter to the serverside while changing the dropdown value.
2. Please confirm your product version whether you are using 12.1.0.43 or 12.4.0.24. Because you have mentioned the version as 12.1.0.24 which is not available.
3. And also please provide us full code snippet that you are used for rendering a grid control and events that you are used in your application or please reproduce the reported issue in the attached sample.
Please get back to us with requested details if you have any concern. The provided information will help us to analyze the issue and provide you the response as early as possible.
Regards,
Gowthami V.