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. Image for the cookie policy date

Hierarchial Grid: QueryString not appended to childgrid datasource

Hi,

I am having trouble getting a hierarchial grid working using URL adaptor. Essentially the querystring does not get appended to the child grid datasource. Some code below if that's useful.

var dataManager = ej.DataManager({
                url: "/Reminders/Get?startDate=" + startDate + "&endDate=" + endDate,
                adaptor: new ej.UrlAdaptor()
            });
            var notificationsDataManager = ej.DataManager({
                url: "/Reminders/Notifications",
                adaptor: new ej.UrlAdaptor()
            });
            $("#remindersGrid").ejGrid({
                dataSource: dataManager,
                columns: [
                    { field: "Id", headerText: "Id", isPrimaryKey:true, visible:false},
                    ......        
                ],
                allowPaging: true,
                childGrid: {
                    dataSource: notificationsDataManager,
                    queryString: "Id",
                    columns: [
                        ......
                    ],
                    allowPaging: true
                }
            });
    public ActionResult Get(DateTime? startDate, DateTime? endDate)
        {
            var reminders = _remindersProvider.GetReminders(DateTime.Now, DateTime.Now);
            return Json(new { result = reminders, count = reminders.Count() }, JsonRequestBehavior.AllowGet);
        }       
       
        public ActionResult Notifications(int id)
        {
            var notifications = _remindersProvider.GetReminderNotifications(id);
            return Json(new { result = notifications, count = notifications.Count() }, JsonRequestBehavior.AllowGet);
        }

Any help will be greatly appreciated.

Thanks,
Krishna



3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team April 13, 2016 12:05 PM UTC

Hi Krishna,

Thanks for contacting Syncfusion support.

We created a sample in hierarchical grid using URL Adaptor and we able to append the child grid using queryString.  In your code snippet, we found that you have mentioned the id as a parameter in the controller. So, we suggest you to use DataManager as a parameter in the controller. DataManager parameter contains all the required parameters for  performing server side operations such as paging, sorting, searching and filtering. We suggest you to use Execute method of DataOperations class for performing server side operations.

When we open the child grid the dataManager parameter contains the query under where property of dataManager and filter the data.

Please find the screenshot:

 

Please find the code example and sample:


<script type="text/javascript">

    var dataManager = ej.DataManager({

        url: "/Grid/DataSource",

        adaptor: new ej.UrlAdaptor()

    });

    var notificationsDataManager = ej.DataManager({

        url: "/Grid/DataSource2",

        adaptor: new ej.UrlAdaptor()

    });

    $("#FlatGrid").ejGrid({

        dataSource: dataManager,

        allowSorting: true,

        columns: [

               ---------------------------------------

       ],

        childGrid: {

            dataSource: notificationsDataManager,

           queryString: "EmployeeID",

            allowPaging: true,

            columns: [

              ---------------------------------------

           ],

           

        },


    });


</script>


Sample: https://www.syncfusion.com/downloads/support/forum/123703/ze/Sample118577-743703497

Regards,
Prasanna Kumar N.S.V



KR Krishna April 16, 2016 12:47 PM UTC

Thanks Prasanna, works.

Thanks,
Krishna


PK Prasanna Kumar Viswanathan Syncfusion Team April 18, 2016 08:43 AM UTC

Hi Krishna,
 
We are happy that the provided solution working fine at your end.
 
Regards,

Prasanna Kumar N.S.V

Loader.
Live Chat Icon For mobile
Up arrow icon