- Home
- Forum
- ASP.NET MVC
- Childgrid binding with two querystring parameters
Childgrid binding with two querystring parameters
{
int id_ponteggio = Convert.ToInt32(dm.Where[0].value);
Hello Syncfusion team,I have an ejGrid (13.3.0.7) with remote databind.I have a childgrid also (with remote databind).This is my code:public JsonResult getPermessiLavoro(DataManager dm)@(Html.EJ().Grid<Ponteggio>("tbListaPonteggi").Datasource(ds => ds.URL(Url.Action("getListaPonteggi", "Registro")).Adaptor(AdaptorType.UrlAdaptor)).Columns(col =>{col.Field("id_ponteggio").IsPrimaryKey(true).Visible(false).Add();col.Field("id_server").Visible(false).Add();col.Field("Nome").HeaderText("Nome ponteggio").Add();}).ChildGrid<PermessoLavoro>(child =>{child.Datasource(ds => ds.URL(Url.Action("getPermessiLavoro", "Registro")).Adaptor(AdaptorType.UrlAdaptor) ).QueryString("id_ponteggio").Columns(col =>{col.Field("id_permesso_lavoro").IsPrimaryKey(true).Visible(false).Add();col.Field("Numero").HeaderText(NomiColonne.colNumPermessoLavoro).Width(100).Add();});}))When the user expands a row in the parentgrid, I use this code to get the QueryString value (used to get childgrid):[HttpPost]
{
int id_ponteggio = Convert.ToInt32(dm.Where[0].value);//...}However, I need to pass the 'id_server' field (of the main row) also.I try with:.ChildGrid<PermessoLavoro>(child =>{child.Datasource(ds => ds.URL(Url.Action("getPermessiLavoro", "Registro")).Adaptor(AdaptorType.UrlAdaptor) ).QueryString("id_ponteggio, id_server")......but doesn't work.How can I solve this problem?I readp.s. I'm sorry for bad english
I read this post but I want to know if there's a more elegant way.
Thanks for using Syncfusion products.
We can pass multiple querystring parameters to Child Grid using “Load” event and query property of Grid. Please refer to the following code example.
|
@(Html.EJ().Grid<object>("ParentGrid") … .ChildGrid(childnew => { childnew.Datasource(ds => ds.URL("/Home/ChildData")
.Adaptor(AdaptorType.UrlAdaptor)) .QueryString("EmployeeID") .ClientSideEvents(eve => eve.Load("childLoad")) … }))
<script> function childLoad(args) { // we can get Parent details in parentDetails property var data = this.model.parentDetails.parentRowData.ShipCountry; this.model.query.addParams("Country", data); } </script>
public ActionResult ChildData(DataManager dm, string Country) { … } |
For your convenience we have created a sample that can be downloadable from the following location.
Sample: http://www.syncfusion.com/downloads/support/forum/120879/ze/Sample625385753-1830991924
Regards,
Alan Sangeeth S
Hi Omar,
Thanks for your update.
We are happy that the provided information helped you.
Regards,
Saravanan A.
<script>
function childLoad(args) {
// we can get Parent details in parentDetails property
var data = this.model.parentDetails.parentRowData.CourseCrn;
this.model.query.addParams("CRN", data);
}
</script>
function childLoad(args) {
var data = this.model.parentDetails.parentRowData.{YourField};
if (this.model.query == null) {
this.model.query = new ej.Query();
}
this.model.query.addParams("{yourParamName}", data);
}
If you turn on caching you will get the same data from each subrow based on the single field you have listed as your QueryString as it appears this same information is used as the key in the Cache.
- 9 Replies
- 6 Participants
-
OM Omar Muscatello
- Oct 24, 2015 02:07 PM UTC
- Feb 14, 2017 01:28 PM UTC